Обход бага .net

This commit is contained in:
Фролов 2021-07-29 12:36:29 +05:00
parent 1e878aaa03
commit 59a86e4c4b

View File

@ -24,7 +24,8 @@ namespace AsbCloudInfrastructure.Services.Cache
public int Refresh() public int Refresh()
{ {
cached.Clear(); if(cached.Any())
cached.Clear();
var dbEntities = context.Set<TEntity>().ToList(); var dbEntities = context.Set<TEntity>().ToList();
cached.AddRange(dbEntities); cached.AddRange(dbEntities);
data.refreshDate = DateTime.Now; data.refreshDate = DateTime.Now;
@ -33,7 +34,8 @@ namespace AsbCloudInfrastructure.Services.Cache
public async Task<int> RefreshAsync(CancellationToken token = default) public async Task<int> RefreshAsync(CancellationToken token = default)
{ {
cached.Clear(); if (cached.Any())
cached.Clear();
var dbEntities = await context.Set<TEntity>().ToListAsync(token).ConfigureAwait(false); var dbEntities = await context.Set<TEntity>().ToListAsync(token).ConfigureAwait(false);
cached.AddRange(dbEntities); cached.AddRange(dbEntities);
data.refreshDate = DateTime.Now; data.refreshDate = DateTime.Now;