Skip to main content
.NET Framework 4.5.2+

Session.CreateObjectTypeRecordsAsync(CancellationToken, Assembly[]) Method

Asynchronously stores valid persistent types for all the types which are defined within the specified assemblies.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public Task CreateObjectTypeRecordsAsync(
    CancellationToken cancellationToken,
    params Assembly[] assemblies
)

Parameters

Name Type Description
cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

assemblies Assembly[]

An array of assemblies which contain the class types for which the persistent types will be stored in the metadata information.

Returns

Type Description
Task

A Task that stores valid persistent types for all the types which are defined within the specified assemblies.

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 to store valid persistent types for all the class types which are defined within the assemblies that are passed as the assemblies parameter. This creates all the necessary records within a special table called XPObjectType which is used to support object polymorphism.

using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
// ...
public async Task CreateDatabase(string connectionString, params Assembly[] assemblies) {
    using(IDataLayer dal = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema)) {
        UnitOfWork uow = new UnitOfWork(dal);
        await uow.UpdateSchemaAsync(CancellationToken.None, assemblies);
        await uow.CreateObjectTypeRecordsAsync(CancellationToken.None, assemblies);
    }
}
See Also