Session.UpdateSchemaAsync(CancellationToken, Boolean, XPClassInfo[]) Method
Asynchronously updates the database schema to support the persistence of the objects with the specified 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. |
doNotCreateIfFirstTableNotExist | Boolean | true if the schema should not be created when the table that corresponds to the first item in the types array doesn’t exist in the data store; otherwise, false. |
types | XPClassInfo[] | An array of XPClassInfo objects that specify the types of objects for which schema should be created in the data store. |
Returns
Type | Description |
---|---|
Task<UpdateSchemaResult> | A Task<TResult> that returns an UpdateSchemaResult enumeration value which specifies the result of the update operation. |
Remarks
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, true, persistentClasses);
}
}