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

How to: Speed Up Performance When Using WCF Data Services (OData) in Instant Feedback Mode

  • 2 minutes to read

The DXGrid can load data from a SQL Server Database, using WCF Data Services, that implements the Open Data Protocol (OData). To load and manage data (group, sort, filter, calculate summary, etc.), DXGrid uses DataServiceQuery that implements the IQueryable interface. Queries are first evaluated on the client, and then a URI-based query is generated and sent to the data service. However, the URI syntax used by OData data services supports only six query operators: Select, Where, OrderBy, ThenBy, Skip and Take. Due to this limitation, DXGrid cannot retrieve required data (e.g., unique column values, evaluated summaries, group info, etc.) from a SQL Server Database in a single query. Instead, DXGrid sends multiple queries. This dramatically slows down the client application’s performance.

To avoid this performance decrease, do the following.

  • For each ObjectSet<TEntity> type property in the ObjectContext descendant, implement a data service method that calls an auxiliary DevExpress method. Use the following name syntax: GetPropertyNameExtendedData. For example, the corresponding method for the Orders property should be GetOrdersExtendedData.
  • Apply [WebGet(UriTemplate = “GetOrdersExtendedData?extendedDataInfo={extendedDataInfo}”)] attribute to the data service method.
  • Set the access rights on a service operation when the service is being initialized.
  • Enable the WcfInstantFeedbackDataSource.UseExtendedDataQuery option.

Example

public class WcfSCService : DataService<NWindEntities> {
    // The data service method for Orders.
    [WebGet(UriTemplate = "GetOrdersExtendedData?extendedDataInfo={extendedDataInfo}")]
    public string GetOrdersExtendedData(string extendedDataInfo) {
        return DevExpress.Xpf.Core.ServerMode.ExtendedDataHelper.GetExtendedData(GetCustomerOrders(),
new DevExpress.Data.Linq.CriteriaToEFExpressionConverter(), extendedDataInfo);
    }
    // Set the access rights on a service operation.
    public static void InitializeService(DataServiceConfiguration config) {
        config.SetServiceOperationAccessRule("GetOrdersExtendedData", ServiceOperationRights.AllRead);
    }
}

Limitation

A string parameter passed to a data service method that obtains extended data has the maximum allowed length that is defined by a browser (e.g., for IE it is 2083 symbols) and a web server. If the parameter’s length exceeds the maximum allowed width, a data query cannot be extended and an exception is thrown.