diff --git a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs index 735a0295..f317753b 100644 --- a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs +++ b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs @@ -26,7 +26,7 @@ namespace AsbCloudInfrastructure.Services.Cache { if (cached.Any()) cached.Clear(); - var dbEntities = context.Set().ToList(); + var dbEntities = context.Set().AsNoTracking().ToList(); cached.AddRange(dbEntities); data.refreshDate = DateTime.Now; return cached.Count; @@ -36,7 +36,7 @@ namespace AsbCloudInfrastructure.Services.Cache { if (cached.Any()) cached.Clear(); - var dbEntities = await context.Set().ToListAsync(token).ConfigureAwait(false); + var dbEntities = await context.Set().AsNoTracking().ToListAsync(token).ConfigureAwait(false); cached.AddRange(dbEntities); data.refreshDate = DateTime.Now; return cached.Count; @@ -225,7 +225,7 @@ namespace AsbCloudInfrastructure.Services.Cache foreach (var entity in entities) { Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry updated; - if (dbSet.Contains(entity)) + if (dbSet.Contains(entity)) // TODO: это очень ммедленно updated = dbSet.Update(entity); else updated = dbSet.Add(entity);