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

XPServerCollectionSource.ObjectClassInfo Property

Gets a XPClassInfo object that describes the target data table in the data store.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v18.2.dll

Declaration

[DefaultValue(null)]
[TypeConverter("DevExpress.Xpo.Design.ObjectClassInfoTypeConverter, DevExpress.Xpo.v18.2.Design, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
public XPClassInfo ObjectClassInfo { get; set; }

Property Value

Type Default Description
XPClassInfo *null*

An XPClassInfo object that describes the target data table in the data store.

Remarks

The XPServerCollectionSource.ObjectType and XPServerCollectionSource.ObjectClassInfo properties provide information that describes the target data table. These properties are synchronized. When initializing the XPServerCollectionSource.ObjectType property, the XPServerCollectionSource.ObjectClassInfo property is initialized with a matching object, and vice versa.

Do not change the XPServerCollectionSource.ObjectType and XPServerCollectionSource.ObjectClassInfo properties directly in your code. Instead, initialize these properties via the objectClassInfo or objectType parameter of the XPServerCollectionSource‘s constructor.

See the XPServerCollectionSource topic, for information on how to provide descriptive information on the target data table.

Example

In the following code, an XPServerCollectionSource object is initialized with a persistent object describing a target “Person.Contact” data table (this table is included in the AdventureWorks database that ships with MS SQL Server).

In the code, the Person_Contact persistent object is declared, and mapped to the “Person.Contact” data table using the PersistentAttribute attribute. It exposes specific public properties that match the data table’s fields.

To provide data on the Person_Contact object for the XPServerCollectionSource, first a corresponding XPClassInfo object is obtained. Then it’s passed to the XPServerCollectionSource’s constructor via an objectClassInfo parameter. This initializes the XPServerCollectionSource.ObjectClassInfo property.

using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
using DevExpress.Data.Filtering;

public Form1() {
    // ...
    // Create an XPClassInfo object corresponding to the Person_Contact class.
    XPClassInfo classInfo = XpoDefault.Session.GetClassInfo(typeof(Person_Contact));
    // Create a filter that selects records which contain names starting with 'A' 
    // in the LastName column
    CriteriaOperator criteria = CriteriaOperator.Parse("[LastName] LIKE ?", "A%");
    //Create a data source.
    XPServerCollectionSource serverModeDS = new XPServerCollectionSource(
      XpoDefault.Session, classInfo, criteria);
}

// ...

// The persistent object that describes the "Person.Contact" table 
// in the AdventureWorks SQL database.
[Persistent("Person.Contact")]
public class Person_Contact : XPLiteObject {        
    [Key]
    public System.Int32 ContactID;
    public string FirstName;
    public string LastName;
    //...
}

Example

The following code shows how to initialize an XPServerCollectionSource object with a typed DataTable object.

It’s assumed that a project contains a DataSet class (AdventureWorksDataSet) which owns the target DataTable (_Person_ContactDataTable). In the code, first a XPClassInfo object corresponding to the data table is created. Then it’s passed to the XPServerCollectionSource object’s constructor via the objectClassInfo parameter, initializing the XPServerCollectionSource.ObjectClassInfo property.

using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;

// Create an XPClassInfo object corresponding to the _Person_ContactDataTable data table.
XPClassInfo classInfo = XpoDefault.Session.GetClassInfo(
  typeof(AdventureWorksDataSet._Person_ContactDataTable));
// Create a data source.
XPServerCollectionSource serverModeDS = new XPServerCollectionSource(
  XpoDefault.Session, classInfo);
See Also