Search code examples
devexpressxtrareport

Devexpress Reports and DBContext Datasource


I am using Devexpress in VS2013. i want to know how can I use my entity framework classes as data source in Devexpress reports(XtraReport). e.g I have a DBset "Employs" in my my DBcontext how can i use it in Xtrareport Data source,

Thanks.


Solution

  • You can easily bind the report to the EF query result if you convert your query to the List and then bind your report to this List:

    report.DataSource = (from employee in DbContext.Employees
                        select employee).ToList();
    

    I believe the following KB article will be helpful:
    How to create a master-detail report bound to an ORM (Entity Framework) model in MVC applications