Skip to main content
.NET 8.0+

XPInstantFeedbackSource Class

The data source for a GridControl and SearchLookUpEdit controls that binds these controls to data in Instant Feedback Mode.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.2.dll

Declaration

public class XPInstantFeedbackSource :
    Component,
    IListSource,
    IXPClassInfoProvider,
    IXPDictionaryProvider,
    IDXCloneable

Remarks

Instant Feedback binding mode is an improvement over the regular server mode. In server mode, the XtraGrid loads data in small portions and delegates all data operations (sorting, grouping, filtering and calculating summaries) to the data server. This is the key to the server mode’s high efficiency when working with large volumes of data. The only drawback to using server mode involves data operations when the connection to the server is slow. In this instance, the bound control freezes until the data server completes operations and retrieves results. With Instant Feedback binding mode, data operations are performed asynchronously in a background thread, and both the bound control and the application remain highly responsive. Currently, this mode is supported by the GridControl and SearchLookUpEdit controls.

A data source supporting Instant Feedback mode must either implement the DevExpress.Data.Async.IAsyncListServer interface or implement the IListSource interface and return an IAsyncListServer instance via the IListSource.GetList method. The XPInstantFeedbackSource component implements the IListSource interface, and returns the list implementing the IAsyncListServer interface via the IListSource.GetList method.

The XPInstantFeedbackSource object serves as a conduit of information between the control and a target data store. When the control needs to display a specific portion of data, it calls a specific method of the bound XPInstantFeedbackSource object. This method sends a corresponding request to the data store, and while receiving the results, immediately passes them back to the control.

When creating an XPInstantFeedbackSource object, you need to provide descriptive information on the target data table (view) in the target data store. Declare a persistent class (an XPBaseObject descendant) that will correspond to the data table (see Basics of Creating Persistent Objects for Existing Data Tables). Then, pass the persistent class type to the XPInstantFeedbackSource constructor. You can use the XPInstantFeedbackSource.ObjectType property, to choose the required persistent class at design time. In Instant Feedback mode, the target data table must contain a single key field, and the persistent class must contain a public property corresponding to the table key. If the data table does not contain a key field or the key is composed of several columns, it cannot be used as a data source.

Note

The XPInstantFeedbackSource is a read-only data source. To enable data editing in server mode, use the XPServerCollectionSource with the XPServerCollectionSource.AllowEdit property set to true.

The XPInstantFeedbackSource can only work with thread-safe properties. Reference properties are not thread safe. So, you should not use reference property descriptors when specifying XPInstantFeedbackSource.DisplayableProperties.

Assign the XPInstantFeedbackSource.DefaultSorting, XPInstantFeedbackSource.DisplayableProperties, XPInstantFeedbackSource.FixedFilterCriteria, XPInstantFeedbackSource.FixedFilterString, and XPInstantFeedbackSource.ObjectType properties before binding the XPInstantFeedbackSource to the GridControl or SearchLookUpEdit. Once bound, changing any of these properties throws an exception.

For additional information on Instant Feedback mode, refer to Large Data Sources: Server and Instant Feedback Modes.

Example

This example demonstrates how to initialize a XPInstantFeedbackSource, to retrieve data from a “Person.Contact” data table (included in the AdventureWorks database shipped with Microsoft SQL Server). The Person_Contact persistent class is declared, and mapped to the “Person.Contact” data table, using the PersistentAttribute attribute. Then, this class is used as a parameter in the XPInstantFeedbackSource constructor.

using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Data.Filtering;

// The persistent class describing the "Person.Contact" table 
// from the AdventureWorks SQL database
[Persistent("Person.Contact")]
public class Person_Contact : XPLiteObject {        
    [Key]
    public System.Int32 ContactID {
        get { return fContactID; }
        set { SetPropertyValue(nameof(ContactID), ref fContactID, value); }
    }
    System.Int32 fContactID;

    public string FirstName {
        get { return fFirstName; }
        set { SetPropertyValue(nameof(FirstName), ref fFirstName, value); }
    }
    string fFirstName;

    public string LastName {
        get { return fLastName; }
        set { SetPropertyValue(nameof(LastName), ref fLastName, value); }
    }
    string fLastName;

    //...
}
public partial class Form1 : Form {
    //...
    public Form1() {
        // ...
        // Create a filter that selects records where last names start with 'A'     
        CriteriaOperator criteria = CriteriaOperator.Parse("[LastName] LIKE ?", "A%");
        // Specify the properties that will be available for binding
        string displayableProperties = "FirstName;LastName";    
        // Initialize an XPInstantFeedbackSource data source 
        // supplying data from the Person.Contact data table     
        XPInstantFeedbackSource instantDS = new XPInstantFeedbackSource(
            typeof(Person_Contact), displayableProperties, criteria);
        // Handle the ResolveSession event, 
        // to provide a Session to the XPInstantFeedbackSource
        instantDS.ResolveSession += instantDS_ResolveSession;
        // Handle the DismissSession event, to dispose of the Session
        instantDS.DismissSession += instantDS_DismissSession;
        //...
    }
    void instantDS_ResolveSession(object sender, ResolveSessionEventArgs e) {
        Session session = new Session();
        session.ConnectionString = @"Integrated Security=SSPI;Pooling=false;
            Data Source=.\SQLEXPRESS;Initial Catalog=MyDatabase";
        session.Connect();
        e.Session = session;
    }
    void instantDS_DismissSession(object sender, ResolveSessionEventArgs e) {
        IDisposable session = e.Session as IDisposable;
        if(session != null) {
            session.Dispose();
        }
    }
}

Inheritance

Object
MarshalByRefObject
Component
XPInstantFeedbackSource
See Also