From f18886639123574a3b8a9ac399c3d32bb9879590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 18 Apr 2024 09:40:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BE=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudInfrastructure/DependencyInjection.cs | 5 +++++ AsbCloudInfrastructure/Repository/CacheBase.cs | 2 +- .../Repository/SetpointsRequestRepository.cs | 5 +++++ AsbCloudInfrastructure/Services/SAUB/SetpointsService.cs | 6 ++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs index 6e8b3e89..713f5614 100644 --- a/AsbCloudInfrastructure/DependencyInjection.cs +++ b/AsbCloudInfrastructure/DependencyInjection.cs @@ -52,6 +52,11 @@ namespace AsbCloudInfrastructure { public static void MapsterSetup() { + TypeAdapterConfig.GlobalSettings.Default.Config + .ForType() + .Ignore(source => source.Author) + .Ignore(source => source.Well); + TypeAdapterConfig.GlobalSettings.Default.Config .ForType() .Ignore(source => source.OperationCategory); diff --git a/AsbCloudInfrastructure/Repository/CacheBase.cs b/AsbCloudInfrastructure/Repository/CacheBase.cs index 28d07f07..84f702df 100644 --- a/AsbCloudInfrastructure/Repository/CacheBase.cs +++ b/AsbCloudInfrastructure/Repository/CacheBase.cs @@ -53,7 +53,7 @@ namespace AsbCloudInfrastructure.Repository cacheEntry.AbsoluteExpirationRelativeToNow = CacheObsolescence; cacheEntry.SlidingExpiration = CacheObsolescence; - var entities = await this.GetQuery().ToArrayAsync(token); + var entities = await GetQuery().AsNoTracking().ToArrayAsync(token); cacheEntry.Value = entities; return entities.AsEnumerable(); }); diff --git a/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs b/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs index 2c1f7905..c2b359db 100644 --- a/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs +++ b/AsbCloudInfrastructure/Repository/SetpointsRequestRepository.cs @@ -40,9 +40,14 @@ namespace AsbCloudInfrastructure.Repository { var entity = Convert(dto); var entry = dbSet.Update(entity); + entry.State = EntityState.Detached; } var affected = await dbContext.SaveChangesAsync(token); + + if(affected > 0) + DropCache(); + return affected; } diff --git a/AsbCloudInfrastructure/Services/SAUB/SetpointsService.cs b/AsbCloudInfrastructure/Services/SAUB/SetpointsService.cs index d06e0b4c..383c587f 100644 --- a/AsbCloudInfrastructure/Services/SAUB/SetpointsService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/SetpointsService.cs @@ -2,7 +2,6 @@ using AsbCloudApp.Services; using AsbCloudDb.Model; using AsbCloudInfrastructure.Repository; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using System; using System.Collections.Generic; @@ -62,9 +61,8 @@ namespace AsbCloudInfrastructure.Services.SAUB var all = await setpointsRepository.GetAllAsync(token); var filtered = all.Where(s => s.IdWell == idWell && - s.IdState == 1 && - s.UploadDate.AddSeconds(s.ObsolescenceSec) > DateTime.UtcNow) - .ToList(); + s.IdState == 1 && + s.UploadDate.AddSeconds(s.ObsolescenceSec) > DateTime.UtcNow); if (!filtered.Any()) return Enumerable.Empty();