Binding to a Data Source Using Entity Framework

This example shows how to generate model and mapping information and bind the pivot grid to the data source using Entity Framework.

Creating Data Classes

  • Add ADO.NET Entity Data Model to the project.

    ASP.NET Server Mode - Add Entity Model

  • Follow the wizard steps to generate a new data model using the code-first or database-first development approach.

    ASP.NET Server Mode - model.edmx

  • Save the generated model, close the EDMX diagram, and rebuild the solution

Binding the ASPxPivotGrid control to the EntityServerModeSource component

If the database table that is used to generate a EDMX diagram does not have a primary key, handle the EntityServerModeDataSource.Selecting event and specify the LinqServerModeDataSourceSelectEventArgs.KeyExpression and LinqServerModeDataSourceSelectEventArgs.QueryableSource properties.

using DevExpress.Data.Linq;

protected void EntityServerModeDataSource1_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
{
    e.KeyExpression = "OrderID";
    e.QueryableSource = new ASP.NETEntityServerMode.NWindEntities().SalesPersons;
}
See Also