This example demonstrates how to create a master-detail report bound to Object Relational Model in ASP.NET MVC applications.
This example uses the Entity Framework ORM model to provide a report with data, but you can use any object model instead.
Bind your XtraReport to your model master class by using the approach suggested in the Providing Data to a Web Report => Design-Time Data Binding Using BindingSource help topic. After your report is bound to the master class you can easily insert a detail report band by using the context menu in the report designer, as shown below:
FAQ:
- Why does the "Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data." exception occur?
This example uses Entity Framework 4 so you can easily bind the report to the query result. However note that starting with Entity Framework 4.1 you can not bind components to queries, so you need to convert your query to the List and then bind your report to this List. Use the following code for this purpose:
[C#]report.DataSource=(fromcategoryinDataContext.Categoriesselectcategory).ToList();
[VB.NET]report.DataSource = _ (From category In DataContext.Categories _Select category).ToList()
See also:
How to bind a report displayed in the DocumentViewer extension to the model's data