Add AsNoTracking to MemoryCacheExtentions.

This commit is contained in:
ngfrolov 2023-06-20 15:41:36 +05:00
parent 2e0206c6a0
commit 7ef0954a9d
Signed by untrusted user who does not match committer: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 7 additions and 2 deletions

View File

@ -23,10 +23,12 @@ namespace AsbCloudInfrastructure
/// <param name="token"></param>
/// <returns></returns>
public static Task<IEnumerable<T>> GetOrCreateBasicAsync<T>(this IMemoryCache memoryCache, IQueryable<T> query, CancellationToken token)
where T : class
{
var getter = async (CancellationToken token) =>
{
var entities = await query
.AsNoTracking()
.ToArrayAsync(token);
return entities.AsEnumerable();
};
@ -63,8 +65,11 @@ namespace AsbCloudInfrastructure
/// <param name="query"></param>
/// <returns></returns>
public static IEnumerable<T> GetOrCreateBasic<T>(this IMemoryCache memoryCache, IQueryable<T> query)
where T : class
{
var getter = () => query.ToArray();
var getter = () => query
.AsNoTracking()
.ToArray();
return memoryCache.GetOrCreateBasic(getter);
}

View File

@ -83,7 +83,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
throw new Exception($"Telemetry id: {idTelemetry} does not exist.");
if (telemetry.Well?.Timezone is not null)
return telemetry.TimeZone.Adapt<SimpleTimezoneDto>();
return telemetry.Well.Timezone.Adapt<SimpleTimezoneDto>();
if (telemetry.TimeZone is not null)
return telemetry.TimeZone.Adapt<SimpleTimezoneDto>();