forked from ddrilling/AsbCloudServer
Add AsNoTracking to MemoryCacheExtentions.
This commit is contained in:
parent
2e0206c6a0
commit
7ef0954a9d
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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>();
|
||||
|
Loading…
Reference in New Issue
Block a user