make db context creation async

This commit is contained in:
MarcoCoreDuo
2025-12-31 07:43:07 +01:00
parent 09a1c31fa3
commit adaca95590

View File

@@ -751,18 +751,21 @@ public sealed class BaseItemRepository
ArgumentNullException.ThrowIfNull(item);
cancellationToken.ThrowIfCancellationRequested();
using var context = _dbProvider.CreateDbContext();
var dbContext = await _dbProvider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
var userKeys = item.GetUserDataKeys().ToArray();
var retentionDate = (DateTime?)null;
await context.UserData
.Where(e => e.ItemId == PlaceholderId)
.Where(e => userKeys.Contains(e.CustomDataKey))
.ExecuteUpdateAsync(
e => e
.SetProperty(f => f.ItemId, item.Id)
.SetProperty(f => f.RetentionDate, retentionDate),
cancellationToken).ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false))
{
var userKeys = item.GetUserDataKeys().ToArray();
var retentionDate = (DateTime?)null;
await dbContext.UserData
.Where(e => e.ItemId == PlaceholderId)
.Where(e => userKeys.Contains(e.CustomDataKey))
.ExecuteUpdateAsync(
e => e
.SetProperty(f => f.ItemId, item.Id)
.SetProperty(f => f.RetentionDate, retentionDate),
cancellationToken).ConfigureAwait(false);
}
}
/// <inheritdoc />