Skip to main content

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

  • 2 minutes to read

To enable server mode, you need to create an appropriate 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

  • Add LINQ to SQL Classes to the project.

    ASP.NET Server Mode - Add LINQ Model

  • 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 topic.

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

    ASP.NET Server Mode - OR Designer

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

Binding the ASPxPivotGrid control to the LinqServerModeSource component

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

using DevExpress.Data.Linq;

protected void LinqServerModeDataSource1_Selecting(object sender, LinqServerModeDataSourceSelectEventArgs e)
{
    e.KeyExpression = "OrderID";
    e.QueryableSource = new ASP.NETLinqServerMode.DataClasses1DataContext().SalesPersons;
}
See Also