Binding to a Data Source Using Entity Framework

The PivotGridControl automatically operates in server mode if it is bound to appropriate supported data source. This example illustrates how to generate model and mapping information, and how to bind the pivot grid to a data source using the Entity Framework.

Creating Data Classes

  1. Add an ADO.NET Entity Data Model to the project.

    WPF Server Mode - Add Entity Component

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

    WPF Server Mode - Create EDMX Diagram.png

  3. Save the generated model, close the EDMX diagram, and rebuild the solution.

Binding the Pivot Grid control to the EntityServerModeDataSource component.

  1. Create a new instance of the EntityServerModeDataSource class. Specify the type of objects retrieved from a data source EntityServerModeDataSource.KeyExpression and EntityServerModeDataSource.QueryableSource properties. Finally, bind the Pivot Grid control to the EntityServerModeDataSource component.

    using DevExpress.Xpf.Core.ServerMode;
    public MainWindow()
        pivotGridControl1.DataSource = new EntityServerModeDataSource()
            KeyExpression = "OrderID",
            QueryableSource = new NWindEntities().SalesPersons
See Also