Session.CreateObjectTypeRecordsAsync(CancellationToken, XPClassInfo[]) Method
Asynchronously stores valid persistent types for the specified persistent class metadata information.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
NuGet Package: DevExpress.Xpo
Declaration
Parameters
Name | Type | Description |
---|---|---|
cancellationToken | CancellationToken | A CancellationToken object that delivers a cancellation notice to the running operation. |
types | XPClassInfo[] | An array of the XPClassInfo objects for which the persistent types will be stored in the metadata information. |
Returns
Type | Description |
---|---|
Task | A Task that stores valid persistent types for the specified persistent class metadata information. |
Remarks
For thread-safe data access layers (see ThreadSafeDataLayer) to function correctly, it’s necessary to provide complete metadata information on the persistent objects in a data store before performing any operations with persistent objects. Call the CreateObjectTypeRecordsAsync method and pass persistent class metadata information as the types parameter to store valid persistent types for the corresponding persistent objects. This creates all the necessary records within a special table called XPObjectType which is used to support object polymorphism.
using System.Threading;
using System.Threading.Tasks;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Xpo.Metadata;
// ...
public async Task CreateDatabase(string connectionString, params XPClassInfo[] persistentClasses) {
using(IDataLayer dal = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema)) {
UnitOfWork uow = new UnitOfWork(dal);
await uow.UpdateSchemaAsync(CancellationToken.None, persistentClasses);
await uow.CreateObjectTypeRecordsAsync(CancellationToken.None, persistentClasses);
}
}