-
Notifications
You must be signed in to change notification settings - Fork 520
Expand file tree
/
Copy pathSqlDialectInitializer.cs
More file actions
26 lines (22 loc) · 953 Bytes
/
SqlDialectInitializer.cs
File metadata and controls
26 lines (22 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Microsoft.EntityFrameworkCore;
using Squidex.Hosting;
namespace Squidex.Infrastructure.Queries;
public sealed class SqlDialectInitializer<TContext>(IDbContextFactory<TContext> dbContextFactory)
: IInitializable where TContext : DbContext
{
public async Task InitializeAsync(CancellationToken ct)
{
await using var dbContext = await dbContextFactory.CreateDbContextAsync(ct);
if (dbContext is not IDbContextWithDialect withDialect)
{
return;
}
await withDialect.Dialect.InitializeAsync(dbContext, ct);
}
}