fix ef Find

This commit is contained in:
Anton Suhorukov 2023-05-30 12:36:46 +03:00
parent 9eeec5cc10
commit 7724669c7e
3 changed files with 5 additions and 17 deletions

View File

@ -66,8 +66,8 @@ public class DbLoginEventsManager
if (id < 0) return null;
using var loginEventContext = _dbContextFactory.CreateDbContext();
return await Queries.FindLoginEventAsync(loginEventContext, id);
return await loginEventContext.LoginEvents.FindAsync(id);
}
public async Task<List<BaseEvent>> GetLoginEventsAsync(int tenantId, Guid userId)
@ -135,10 +135,6 @@ public class DbLoginEventsManager
file static class Queries
{
public static readonly Func<MessagesContext, int, Task<LoginEvent>> FindLoginEventAsync = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery(
(MessagesContext ctx, int id) =>
ctx.LoginEvents.Find(id));
public static readonly Func<MessagesContext, int, Guid, IEnumerable<int>, DateTime, IAsyncEnumerable<LoginEvent>> GetLoginEventsAsync = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery(
(MessagesContext ctx, int tenantId, Guid userId, IEnumerable<int> loginActions, DateTime date) =>
ctx.LoginEvents

View File

@ -87,7 +87,7 @@ class DbQuotaService : IQuotaService
var dbTenantQuotaRow = _mapper.Map<TenantQuotaRow, DbQuotaRow>(row);
dbTenantQuotaRow.UserId = row.UserId;
var exist = await Queries.FindQuotaRowAsync(coreDbContext, dbTenantQuotaRow.Tenant, dbTenantQuotaRow.UserId, dbTenantQuotaRow.Path);
var exist = await coreDbContext.QuotaRows.FindAsync(new object[] { dbTenantQuotaRow.Tenant, dbTenantQuotaRow.UserId, dbTenantQuotaRow.Path });
if (exist == null)
{
@ -135,11 +135,6 @@ file static class Queries
.Where(r => r.Tenant == tenantId)
.SingleOrDefault());
public static readonly Func<CoreDbContext, int, Guid, string, Task<DbQuotaRow>> FindQuotaRowAsync = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery(
(CoreDbContext ctx, int tenantId, Guid userId, string path) =>
ctx.QuotaRows
.Find(new object[] { tenantId, userId, path }));
public static readonly Func<CoreDbContext, int, Guid, string, long, Task<int>> UpdateCounterAsync = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery(
(CoreDbContext ctx, int tenantId, Guid userId, string path, long counter) =>
ctx.QuotaRows

View File

@ -48,7 +48,7 @@ public class BackupRepository : IBackupRepository
public async Task<BackupRecord> GetBackupRecordAsync(Guid id)
{
using var backupContext = _dbContextFactory.CreateDbContext();
return await Queries.FindBackupAsync(backupContext, id);
return await backupContext.Backups.FindAsync(id);
}
public async Task<BackupRecord> GetBackupRecordAsync(string hash, int tenant)
@ -96,7 +96,7 @@ public class BackupRepository : IBackupRepository
{
using var backupContext = _dbContextFactory.CreateDbContext();
var backup = await Queries.FindBackupAsync(backupContext ,id);
var backup = await backupContext.Backups.FindAsync(id);
if (backup != null)
{
@ -133,9 +133,6 @@ public class BackupRepository : IBackupRepository
file static class Queries
{
public static readonly Func<BackupsContext, Guid, Task<BackupRecord>> FindBackupAsync = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery(
(BackupsContext ctx, Guid id) =>
ctx.Backups.Find(id));
public static readonly Func<BackupsContext, int, string, Task<BackupRecord>> GetBackupAsync = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery(
(BackupsContext ctx, int tenantId, string hash) =>