Ticket Q532435
Visible to All Users

How to use Entity Framework with Xtrareports

created 11 years ago

I have an ASP.NET application that uses Entity Framework against a MsSQL database as the data source for the site. I am having a very hard time finding a clearly illustrated tutorial, example or demo of using Entity Framework-Entity Type or a Complex Type as the report data source. I would like to use the Design view to drag / drop fields into the design. I don't want to create Datasets as this defeats the purpose of using the Entity Framework. The closest Devexpress post I have found is How to use the XtraReport with the Entity Framework but this is quite old, uses c# and doesn't appear to have the report designer included.
I would appreciate a simple website example and clear, step by step instructions for creating a xtrareport with Entity Framework.

Thanks!

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hi Chris,
From the information you provided, I conclude that the best way to accomplish your task is to place your Report class and Entity objects into a separate class library. In this case, you will be able to bind the Report to a custom object at design time and provide data at runtime.
To pass data to your Report instance, handle the XtraReport.DataSourceDemanded event, create your Entity objects, and pass them to the XtraReport.DataSource property.
Finally, refer to this class library from your web application in order to use the Report class along with Entity objects.
Attached is an example that demonstrates this approach in action. Please note that I have used a Northwind database as a data source.
I hope this will help you achieve the required functionality.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.