xpo-devexpress-dot-xpo-dot-xpservercollectionsource-564f569b.md
Gets the type of the object that describes the target data table in the data store.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
[Browsable(false)]
[DefaultValue(null)]
public Type ObjectType { get; set; }
<Browsable(False)>
<DefaultValue(Nothing)>
Public Property ObjectType As Type
| Type | Default | Description |
|---|---|---|
| Type | null |
The Type of the object that describes the target data table.
|
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.
In the example, an XPServerCollectionSource object is created that will provide data from the “Person.Contact” table in a target database.
To link the “Person.Contact” database table with the XPServerCollectionSource object, a persistent object (Person_Contact) describing the data table is declared and its type is passed to the XPServerCollectionSource ‘s constructor. The value passed is used to initialize the XPServerCollectionSource.ObjectType property.
The Person_Contact object specifies the name of the target data table via the PersistentAttribute attribute and contains public properties corresponding to the required table’s fields.
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Data.Filtering;
public Form1() {
// ...
// 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 that provides data from the data table
// which is described by the Person_Contact object.
XPServerCollectionSource serverModeDS = new XPServerCollectionSource(
XpoDefault.Session, typeof(Person_Contact), 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;
//...
}
Imports DevExpress.Xpo
Imports DevExpress.Xpo.DB
Imports DevExpress.Data.Filtering
Public Sub New()
InitializeComponent()
' ...
' Create a filter that selects records which contain names starting with 'A'
' in the LastName column
Dim criteria As CriteriaOperator = CriteriaOperator.Parse("[LastName] LIKE ?", "A%")
' Create a data source that provides data from the data table
' which is described by the Person_Contact object.
Dim serverModeDS As XPServerCollectionSource = New XPServerCollectionSource( _
XpoDefault.Session, GetType(Person_Contact), criteria)
End Sub
' The persistent object that describes the "Person.Contact" table
' in the AdventureWorks SQL database.
<Persistent("Person.Contact")> _
Public Class Person_Contact
Inherits XPLiteObject
<Key()> _
Public Property ContactID() As System.Int32
Get
Return fContactID
End Get
Set(ByVal value as System.Int32)
SetPropertyValue(NameOf(ContactID), fContactID, value)
End Set
End Property
Private fContactID As System.Int32
Public Property FirstName() As String
Get
Return fFirstName
End Get
Set(ByVal value as String)
SetPropertyValue(NameOf(FirstName), fFirstName, value)
End Set
End Property
Private fFirstName As String
Public Property LastName() As String
Get
Return fLastName
End Get
Set(ByVal value as String)
SetPropertyValue(NameOf(LastName), fLastName, value)
End Set
End Property
Private fLastName As String
'...
End Class
See Also
XPServerCollectionSource Class