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

List View Data Access Modes Overview

  • 4 minutes to read

This topic describes the process of choosing and applying the different techniques on how you can provide data access in a List View using the Model Editor. Note that choosing the correct technique may be critical to achieving your XAF application’s best performance.

Choose an Appropriate Data Access Mode

The default mode in WinForms and ASP.NET applications is Client Mode, which is appropriate in most cases. The DataView, Server and InstantFeedback modes are intended to improve List View performance, but in different areas. In Mobile applications, only the Server mode is supported.

  • If the database request count is critical, then you should choose DataView mode. In this mode, all data records are fetched by a single request, and then grouping, sorting, and filtering are executed on the client side without additional requests. The DataView mode is appropriate for cases when the current persistent type contains many references to other persistent types, which also include numerous references. In the DataView mode, only data required by visible columns is loaded, while the Client and Server modes trigger multiple requests to load the entire date hierarchy. It is important that you do not use original objects in the DataView mode; this mode creates and uses the XafDataViewRecord objects accordingly.
  • If List View startup time is critical, then you should choose Server or Instant Feedback mode. In these modes, only a few visible objects are fetched by the first request when a List View is opened. However, scrolling, grouping, sorting and filtering lead to additional database requests - requiring data to be loaded on demand. It is important that you do not use original objects in the InstantFeedback mode; this mode creates and uses the XafInstantFeedbackRecord objects accordingly.
  • If the performance is acceptable, use the Client mode. Do not enable Server, Instant Feedback or DataView mode unless you observe a lack of performance. Note that the Server and Instant Feedback modes make no sense if the collection is small and all objects are loaded on the first request, or you have a code that iterates all objects in the collection (such a code leads to loading the entire collection).

Applying Data Access Modes

In the Model Editor, the IModelListView.DataAccessMode property of the Views | <ListView> node specifies how the displayed object collection is accessed. Available values - Client, Server, InstantFeedback and DataView are contained in the CollectionSourceDataAccessMode enumeration.

DataAccessMode

Modes that are not compatible with the current List Editor (specified using the IModelListView.EditorType property) are hidden from the combo box. If you use a custom List Editor, you can specify supported modes using the static DataAccessModeHelper.RegisterEditorSupportedModes method. You can call this method from any code that is executed at design time prior to loading the Model Editor (e.g., from the module’s constructor). Pass the List Editor type and the list of it’s supported modes to this method. By default, all modes are available for a custom List Editor.

You can change the data access mode globally for all List Views (except for the autogenerated nested List Views) using the IModelOptions.DataAccessMode property of the Options node. All manually created List Views, including nested List Views, have the same IModelListView.DataAccessMode property value as the global IModelOptions.DataAccessMode option.

Note, when you create a Collection Source (see ListView.CollectionSource) in code, you can use the CollectionSource constructor with the dataAccessMode parameter.

To display a non-persistent property in the Server, InstantFeedback or Data View mode, apply the PersistentAliasAttribute or CalculatedAttribute attribute to this property declaration. Note that some operations, such as filtering, sorting and grouping, do not work with non-persistent properties in the InstantFeedback and Server modes, and to prevent these operations from execution for non-persistent properties, set the ColumnsListEditor.PreventServerSideOperationsForNonPersistentMembers to true.

See Also