Binding to a Data Source Using 'LINQ to SQL Classes'

  • 2 minutes to read

The PivotGridControl automatically operates in server mode if it is bound to appropriate supported data source. You can use dedicated data sources tailored to work with 'LINQ to SQL Classes'. This example shows how to use LINQ query providers.

Creating Data Classes

  1. Add LINQ to SQL Classes to the project.

    WPF Server Mode - Add LINQ Component

  2. Data classes can then be created and edited in an Object Relational Designer (O/R Designer). An O/R Designer provides a visual design surface for creating LINQ to SQL entity classes and relationships based on objects in a database. To learn more, see the MSDN topic.

    You can create and map entity classes to tables and views by dragging database tables and views from the Server Explorer onto the O/R Designer.

    WPF Server Mode - Create LINQ Model

    Save your changes, close the O/R Designer, and rebuild the solution.

Binding the Pivot Grid control to the LinqServerModeDataSource component

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

    using DevExpress.Xpf.Core.ServerMode;
    
    public MainWindow()
    {
        InitializeComponent();
        pivotGridControl1.DataSource = new LinqServerModeDataSource()
        {
            KeyExpression = "OrderID",
            QueryableSource = new DataClasses1DataContext().SalesPersons
        };
    }
    
See Also