XAF-List View data access mode, xaf-List View Mode

Source: Internet
Author: User

XAF-List View data access mode, xaf-List View Mode
This topic describes how to provide data access in List View. Please note that selecting the correct method is critical for implementing the best performance of the XAF application. Overview of Data Access Modes

 

In the model Editor, choose View><ListView>The node finds the IModelListView. DataAccessMode attribute and specifies how the displayed object set is accessed. Available value: Client,Server,InstantFeedbackAndDataView.

Prompt

When different editors are set by using the IModelListView. EditorType attribute, the value in DataAccessMode does not hide the unsupported mode.

If you use the custom List editor, you can use the static methodDataAccessModeHelper. RegisterEditorSupportedModesSpecify the supported mode.

You can call this method by calling any code that is executed during design before loading the model Editor (for example, the constructor from the module. Pass the List editor type and the list of supported modes to this method. By default, all modes can be used in the Custom List editor.

The default mode isClientIn most casesServer,InstantFeedbackAndDataViewMode is a good way to improve performance, but they use different optimization methods. The following table provides a detailed description of each mode.

Client:

When the list is displayed, all records in the database are read to the client at one time (win is the client, and the web is read from the memory of the web server), no matter how much data is displayed on the interface, all are put in the memory first. Memory Data is operated when sorting, grouping, paging, and filtering are performed.

This looks good. Then, when there is a lot of data and the association is very complicated, loading so much at a time will make us feel very slow (for example, tens of thousands of records) and occupy a lot of memory.

Server:

Suppose we use SQL databases (oracle, mysql, and mssql are all counted). This mode uses SQL statements for grouping, paging, sorting, and filtering, in this way, data does not need to be completely returned. When there is a large amount of data, the pressure will be transferred to the SQL server. Load only the displayed part or a small part of the data and read it whenever necessary. When the data volume is large, it is much faster than the client.

  • If you use an old database whose table has a composite primary key, you cannot use this type of table to provide data in server mode.
  • If you have a control in the List View editor accessed by a custom controller to perform custom sorting or grouping, the Controller may no longer be valid because grouping and sorting are performed by the database server. The custom summary is also calculated on the server side. For more information about server mode restrictions, see the limitations of server mode in XtraGrid.
  • Controls that support server mode cannot completely access the underlying data,In addition, you cannot start filtering, sorting, and grouping operations on the client.. These operations are delegated to the underlying ORM (Entity Framework or XPO), which constructs an appropriate SQL statement and performs queries on the SQL server, to search a small part of data that should be immediately displayed to the user.You cannot filter, sort, and group data based on non-persistent attributes.-You cannot create an SQL query for the running values on the client and execute it on the database server. Therefore,If the attribute is not persistent, disable filtering, grouping, and sorting in server mode..
  • Currently, this server mode is supported by two built-in list editors-GridListEditor. In Windows, the form application and ASPxGridListEditor are used by default. ASP. NET Web applications are used by default.

  In actual use, many problems are encountered: the attribute is not persistent and does not support filtering and sorting. We can consider using PersistentAlias as the server-side computing expression. After using this, we can basically give up the SQL statement function.

InstantFeedback:

This mode is very similar to the server mode. The difference is that,

This data-aware operation is executed asynchronously in the background thread (New Function in 16. X)And control the data retrieved by continuing to respond to user operations (see the instant feedback mode ). This is why the limitations of the conventional (synchronous) server mode also apply to instant feedback. Additional restrictions:
  • This mode can only be used for GridListEditor in WinForms form.
  • InLine editing is not supported.
  • When the reference attributes are sorted, grouping and filtering are automatically replaced by the default attributes of the corresponding referenced objects. For exampleContactIn the list view,Contact. Department. TitleAttribute is used to replaceContact. Department.

DataView:

All data is loaded at one time, but not converted to An ORM object. An array is returned.

  • Non-persistent attributes are not supported, but calculation fields can be used.
  • The referenced property is not directly displayed, but the DefaultProperty in the referenced property is used (specified through XafDefaultProperty ).
  • Supported controls-win: GridListEditor, SchedulerListEditor, and javastgridlisteditor
  • Web: ASPxGridListEditor, ASPxSchedulerListEditor, and aspxjavastgridlisteditor are available in ASP. NET Web.
  • Editing of SchedulerListEditor and ASPxSchedulerListEditor does not support "resources" in this mode ".
  •  Links, cancellation, new creation, deletion, and editing operations in the nested list view are designed to be disabled.The attributes of ListView. CurrentObject, ListView. SelectedObjects, and SimpleActionExecuteEventArgs. SelectedObjects return the view record object instead of the original business object. To obtain a real object, use the ListView. GetObject method. If you use recursive data retrieval in the viewcontroller medium code, you can consider using the Client mode. It is possible that there is no difference between them.
Prompt

 

  • You can modify the Data Access Mode of all list views globally (except the automatically generated nested list views) and set the attributes of IModelOptions. DataAccessMode.OptionNode.
  • All manually created list views, including nested list views, use the IModelListView. DataAccessMode attribute value by default.
  • When you create a CollectionSource in the Code and apply it to ListView, you can useDataAccessModeParameter to specify the mode.
Note:

 

When you define a set attribute but do not use Association to establish a link, you should use the Client mode because you cannot export how to filter the set.

What do you mean? You directly wrote a set attribute in the Code: return new XPCollection <T> ("condition ");

XAF cannot use the server mode, because it is difficult to determine how the "conditions" come from. It cannot be automatically calculated. For example, if you change dynamically, XAF does not know what the rule is.

Important

Use Server,InstantFeedbackOrDataViewTo display non-persistent attributes, use the PersistentAliasAttribute or CalculatedAttribute attribute.

 

How to select an appropriate data access mode

 

Server,InstantFeedbackAndData ViewThe Mode aims to improve the performance of the List View, but should be based on different scenarios.

  • If the number of database requests is a critical issue, You should selectDataViewMode. In this mode, all data records are requested only once, and then grouping, sorting, and filtering are performed on the client without additional requests.Attributes of the reference type will also be loaded once, and the resulting SQL is left join.. InDataViewMode: load only visible columns on the interface. If it is understood as an SQL statement, select a, B, c from xx, and other modes (ClientAndServer) Is to load all columns, then select * from xx * may be more and may also generate more requests. For example, the displayed loading reference attribute is not set, then, several times of loading the reference property will be generated.

  • If the startup time of the list view is very important, you should select Server or InstantFeedback mode. In these modes, only visible objects are loaded at the first request. However, the additional database requests caused by scrolling, grouping, sorting, and filtering are loaded on demand.

  • If the performance is good, You only need to useClientMode. Do not enableServer,InstantFeedbackOrDataViewUnless you cannot accept the sending performance or find a suitable mode. Remember the limitations listed earlier in this topic. Note that if the data volume is small,ServerAndInstantFeedbackThe mode does not make any sense.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.