.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

XPInstantFeedbackSource(Type, String, CriteriaOperator) Constructor

Initializes a new instance of the XPInstantFeedbackSource class for the specified persistent class, with the specified settings.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.1.dll

Declaration

public XPInstantFeedbackSource(
    Type objectType,
    string displayableProperties,
    CriteriaOperator fixedCriteria
)

Parameters

Name Type Description
objectType Type

A Type object that specifies the type of a persistent class describing the target data table. This value is used to initialize the XPInstantFeedbackSource.ObjectType property.

displayableProperties String

A string that is a list of displayable properties, containing property paths separated by semicolons. This parameter value is used to initialize the XPInstantFeedbackSource.DisplayableProperties property.

fixedCriteria CriteriaOperator

A CriteriaOperator object specifying the filter expression applied to data on the data store side.

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 MS 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();
        }
    }
}
See Also