XPServerCollectionSource.ObjectClassInfo Property
Gets a XPClassInfo object that describes the target data table in the data store.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
NuGet Package: DevExpress.Xpo
Declaration
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 Microsoft 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 {
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;
//...
}
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);