Bind Card View to Large Data via EF

  • 3 minutes to read

The ASPxCardView control allows you to bind to large data sets with the EntityServerModeDataSource component. This component fully supports database server mode (which delegates all data processing to the database server), and loads only records to be displayed on screen. This functionality dramatically increases the control’s performance when working with large datasets.

Server mode can be enabled for any Entity Framework (EF) Data Model. The EntityServerModeDataSource component is designed for ASP.NET applications, and serves as the data source for the ASPxCardView control.

When an end user performs data operations (sorting, filtering, etc.), the EntityServerModeDataSource component analyzes the grid’s current state and generates smart queries that retrieve only records to be displayed on screen. These requests are passed to the associated EF Data Model. The EF Data Model translates them into the required queries and executes them.

Note

In Entity Framework versions 4.1 and newer, the EntityServerModeDataSource component is a read-only data source because it provides DbContext instead of ObjectContext. (ObjectContext was used in Entity Framework versions 4.0 and older.) The result is that if you use Entity Framework versions 4.1 and newer, you cannot utilize the built-in ASPxCardView functionality to edit, insert, or delete data.

To enable data modification operations, you need to handle the corresponding ASPxCardView events manually (ASPxCardView.CardUpdating, ASPxCardView.CardInserting, and ASPxCardView.CardDeleting respectively). To learn how to handle these events, see the “Manual CRUD Operations” section of the following KB article: How to implement common scenarios when using ASPxGridView bound with EntityDataSource / Entity Framework.

Example

The EntityServerModeDataSource component allows you to bind ASPxCardView to the ADO.NET Entity Data Model and enable database server mode.

Create Data Classes

  1. Add the ADO.NET Entity Data Model.

    ASPxCardview_ServerMode_EF

  2. Follow the wizard’s steps to generate a new data model with the code-first or database-first development approach.
  3. Save the newly generated model, close the EDMX diagram, and build the solution.

Use the EntityServerModeDataSource Control to Connect to the Data Model

  1. Drag the EntityServerModeDataSource component and drop it onto the Page.
  2. Use the EntityServerModeDataSource.ContextTypeName property to specify the type name of objects retrieved from the data source.
  3. Use the EntityServerModeDataSource.TableName property to specify the data table name.
  4. Bind the ASPxCardView control to the EntityServerModeDataSource component and specify the grid’s ASPxGridBase.KeyFieldName property.

Database Server Mode Limitations

In database server mode, ASPxCardView does not have simultaneous access to bound data in its entirety. This imposes some limitations on the grid’s features, which are still available in regular binding mode. See the following help topic for information on features that are not supported in server mode: Database Server Mode Limitations.

See Also