All docs
V20.2
21.1 (EAP/Beta)
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Standard 2.0+
.NET Framework 4.5.2+
.NET Standard 2.0+

Session.CreateObjectTypeRecordsAsync(Boolean, CancellationToken) Method

Asynchronously stores valid persistent types for all the types which are defined within the assemblies that have been loaded in the current application domain.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v20.2.dll

Declaration

public Task CreateObjectTypeRecordsAsync(
    bool createOnlyNecessary,
    CancellationToken cancellationToken
)

Parameters

Name Type Description
createOnlyNecessary Boolean

true, to create object type records only for types that require this to function properly, such as types from inheritance chains, or types utilizing deferred deletion; false, to create object type records for all persistent types.

cancellationToken CancellationToken

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

Returns

Type Description
Task

A Task that stores valid persistent types for all the types which are defined within the assemblies that have been loaded in the current application domain.

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.Threading;
using System.Threading.Tasks;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
// ...
public async Task CreateDatabase(string connectionString) {
    using(IDataLayer dal = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema)) {
        UnitOfWork uow = new UnitOfWork(dal);
        await uow.UpdateSchemaAsync(CancellationToken.None);
        await uow.CreateObjectTypeRecordsAsync(CancellationToken.None, true);
    }
}
See Also