Skip to main content
A newer version of this page is available. .

Entity Framework 4.0+ Server Mode

  • 2 minutes to read

This document shows you how to generate model and mapping information, create queries that access data and bind the query results to the DXGrid control enabling Server Mode.

Requirements

  • The Entity Framework 4.0+

Creating a Storage Model and Mapping Information

Add the ADO.NET Entity Data Model item template, and configure it using the Entity Data Model Wizard.

  • Step 1

    ef4ServerMode_AddEFitem

  • Step 2

    ef4ServerMode_Wizard1

  • Step 3

    ef4ServerMode_Wizard2

  • Step 4

    ef4ServerMode_Wizard3

  • Step 5

    ef4ServerMode_SaveModel

Binding to DXGrid and Implementing Data Updates

Create a new instance of the EntityServerModeSource class. Specify the type of objects retrieved from a data source, the key expression and queryable source. Finally, bind the DXGrid control to EntityServerModeSource.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <dxg:GridControl Name="grid" AutoPopulateColumns="True">
        <dxg:GridControl.View>
            <dxg:TableView />
        </dxg:GridControl.View>
    </dxg:GridControl>
</Grid>
public MainWindow() {
    InitializeComponent();
    grid.ItemsSource = new EntityServerModeSource() {
        KeyExpression = "ProductID",
        QueryableSource = new NorthwindEntities().Products
    };
}

Entity Framework Server Mode Limitations

Compatibility issues with Entity Framework 6.0 and Entity Framework Server Mode Collections.

Breaking changes introduced in Entity Framework 6.0 caused compatibility issues with Entity Framework Server Mode collections (EntityServerModeDataSource, EntityInstantFeedbackDataSource). Below is the list of limitations.

  • Filtering via the Automatic Filter Row against numeric columns is not supported.
  • Searching via the Search Panel against numeric columns is not supported.
  • Incremental searching against numeric columns is not supported.
  • The following column group intervals are not supported:

    • Date
    • DateMonth
    • DateRange
    • DateYear
    • Default (for DateTime columns)
  • A numeric column as display member of the look-up editor is not supported.
  • The following function operators are not supported in filters and unbound columns.

    • ToStr (if the parameter is an operand property referencing a numeric column)
    • AddDays
    • AddHours
    • AddMilliSeconds
    • AddMinutes
    • AddMonths
    • AddSeconds
    • AddYears
    • DateDiffDay
    • DateDiffHour
    • DateDiffMilliSecond
    • DateDiffMinute
    • DateDiffMonth
    • DateDiffSecond
    • DateDiffYear
    • GetDate
  • The Like binary operator is not supported.

To resolve problems with these limitations, execute the following code in your application’s entry point.

EF 6.0 only:

CriteriaToEFExpressionConverter.EntityFunctionsType = typeof(System.Data.Entity.Core.Objects.EntityFunctions);
CriteriaToEFExpressionConverter.SqlFunctionsType = typeof(System.Data.Entity.SqlServer.SqlFunctions);

In Entity Framework 6.1, the System.Data.Entity.Core.Objects.EntityFunctions is obsolete, and the System.Data.Entity.DbFunctions class should be used.

CriteriaToEFExpressionConverter.EntityFunctionsType = typeof(System.Data.Entity.DbFunctions);
CriteriaToEFExpressionConverter.SqlFunctionsType = typeof(System.Data.Entity.SqlServer.SqlFunctions);
See Also