Binding to a Data Source Using Entity Framework
- 2 minutes to read
The PivotGridControl automatically operates in server mode if it is bound to appropriate supported data source. This example demonstrates how to generate model and mapping information, and bind the pivot grid to the data source using the Entity Framework.
Creating Data Classes
Add ADO.NET Entity Data Model to the project.
Create a model in the EF Designer based on an existing database. You can choose the database connection, settings for the model, and database objects to include in the model. The classes your application will interact with are generated from the model.
You can specify the model by dragging database tables and views from Server Explorer to the model.
Save your changes and rebuild the solution.
Binding a Pivot Grid Control to the EntityServerModeSource component
Drag the EntityServerModeSource component and drop it onto the Form.
Specify the type of objects retrieved from a data source using the EntityServerModeSource.ElementType and EntityServerModeSource.KeyExpression properties.
Specify the queryable source with the EntityServerModeSource.QueryableSource property. This property must be set in code.
Bind the Pivot Grid control to the EntityServerModeSource component.
Note
To learn how to bind the PivotGridControl to data using the Data Source Configuration Wizard, see the Entity Framework Data tutorial.