The Q2 2010 release of Telerik Reporting introduces two new data source components that are aimed at improving the integration with business applications utilizing the ADO.NET Entity Framework or the OpenAccess ORM.
(You can see the new data source components in action in the free webinar tomorrow, Tuesday , Jul 20, 11 am EST. Just register for What’s New in Telerik Reporting and RadControls for WinForms. During the live event attendees will also have the chance to win a Telerik Ultimate Collection, valued at $1999).
Prior to the Q2 2010 Telerik Reporting release, the only option for connecting a report to an existing entity model was to create a class with a custom business logic responsible for all data retrieval from that entity model, and then use the ObjectDataSource component to data-bind the report to it. However that approach had an inconsistent design-time support at best, and also imposed several limitations at runtime, so it was evident a dedicated solution was necessary.
The Q2 2010 release introduces the new EntityDataSource and OpenAccessDataSource components that can be used to connect reports directly to an existing ADO.NET Entity Data Model or an Open Access Data Model respectively. The offered integration with the ADO.NET Entity Framework and the Open Access ORM is now completely seamless both at design-time and at runtime without the need of extra code. There are several benefits when using the EntityDataSource and OpenAccessDataSource components over the ObjectDataSource component:
Each entity model can be treated as a special type of a business object layer generated by the ORM tool. In this regard the EntityDataSource and the OpenAccessDataSource components are similar to the ObjectDataSource component. For example, the following code snippet uses the EntityDataSource component to connect a report to an existing ADO.NET Entity Data Model:
var entityDataSource =
var report =
report.DataSource = entityDataSource;
report.DataSource = entityDataSource
Assign the type of the desired object context to the ObjectContext property of the data source, and the name of the property or method responsible for data retrieval to the ObjectContextMember property. At runtime, the data source component creates a new instance of the given object context, and invokes the specified member to obtain the entities needed by the report. The object context instance is kept alive for the duration of the report generation process and then destroyed automatically, when it is no longer needed by the reporting engine.
Here is a similar code snippet that uses the OpenAccessDataSource component to connect a report to an existing Open Access Data Model:
var openAccessDataSource =
report.DataSource = openAccessDataSource;
report.DataSource = openAccessDataSource
Both the EntityDatasource and the OpenAccessDataSource components offer a great deal of flexibility when connecting to an entity model. For example, let us extend the previous object context using a partial class that defines a method with custom business logic:
.MyEntities.Where(entity => entity.Name == name && entity.Value == value).ToList();
(entity) entity.Name = name
entity.Value = value).ToList()
As usual, specify the type of the object context to the ObjectContext property, and the name of the method to the ObjectContextMember property. Additionally, if the method has any arguments, you can pass data source parameters automatically to them using the Parameters collection. The sample code below illustrates how to do this with the EntityDataSource component:
, ReportParameterType.Integer, 100);
Here is the corresponding code snippet for the OpenAccessDataSource component:
If you need more information in this regard you can visit the following help topics from our online documentation:
If you are interested to see the other new Q2 features of Telerik Reporting, just register for the free
webinar this Tuesday, Jul 20, 11 am EST and check out What’s New in Telerik Reporting and RadControls for WinForms. During the live event
attendees will also have the chance to win a Telerik Ultimate Collection
(valued at $1999).
Stefan’s main interests outside the .NET domain include rock music, playing the guitar and swimming.
Copyright © 2002-2016 Telerik. All rights reserved.
Powered by Telerik