Entity Framework
- 2 minutes to read
The Items Source Configuration Wizard allows you to bind the PivotGridControl to an SQL database using the Entity Framework at design time. This topic guides you through the steps needed to do this.
Click the PivotGridControl’s smart tag and select the Items Source Wizard command.
In the invoked Items Source Configuration Wizard, select Entity Framework…
… and click the New Data Source button placed within the Data Sources area.
The following message will appear.
Click OK.
Make sure that the ADO.NET Entity Data Model item is selected in the invoked dialog. Then, specify the required name and click Add.
To learn how to create a new Entity Framework data model from the existing database, see the following topics: Entity Framework (EF) Documentation.
Important
After you create a data model, rebuild the solution.
After creating a data source, click Items Source Wizard again.
In the invoked Items Source Configuration Wizard, select the created data model.
Click Next.
On the next page, select the required binding method.
- Simple Binding - allows you to bind the PivotGridControl to an Entity Framework data source directly.
- Manipulating Data via ICollectionView - allows you to bind the PivotGridControl to a DataSet using the ICollectionView component that enables collections to have the functionalities of current record management, custom sorting, filtering, and grouping. To learn more, see ICollectionView Specifics.
- Server Side Data Processing - allows you to bind the PivotGridControl to large data sources. To learn more, see Database Server Mode.
Select Simple Binding and click Next.
On the final page, you can specify the table.
Select the required table and click Finish.
The PivotGridControl will be bound to the created data source.
You can now use the Retrieve Fields command to retrieve the available data source fields. To retrieve fields in code, use the PivotGridControl.RetrieveFields method.
Note
Note that the Items Source Configuration Wizard adds the created data source to window resources.
<dx:DXWindow.Resources> <dx:EntitySimpleDataSource x:Key="EntitySimpleDataSource" ContextType="{x:Type local:NorthwindDataModel}" Path="SalesPersons"/> </dx:DXWindow.Resources>
Then, the PivotGridControl is bound to the created data source.
<dxpg:PivotGridControl DataSource="{Binding Data, Source={StaticResource EntitySimpleDataSource}}"/>