diff --git a/aspnet-core/src/CoMon.Application/Assets/AssetAppService.cs b/aspnet-core/src/CoMon.Application/Assets/AssetAppService.cs index f6a9e64..fec4c84 100644 --- a/aspnet-core/src/CoMon.Application/Assets/AssetAppService.cs +++ b/aspnet-core/src/CoMon.Application/Assets/AssetAppService.cs @@ -33,6 +33,7 @@ public async Task Get(long id) .OrderByDescending(s => s.Time) .Take(1)) .AsSplitQuery() + .AsNoTracking() .SingleOrDefaultAsync() ?? throw new EntityNotFoundException("Asset not found."); @@ -45,6 +46,7 @@ public async Task> GetAllPreviews() .GetAll() .Include(a => a.Group.Parent.Parent) .AsSplitQuery() + .AsNoTracking() .ToListAsync(); return _objectMapper.Map>(assets); diff --git a/aspnet-core/src/CoMon.Application/Assistant/AssistantAppService.cs b/aspnet-core/src/CoMon.Application/Assistant/AssistantAppService.cs index 2140830..e8e2981 100644 --- a/aspnet-core/src/CoMon.Application/Assistant/AssistantAppService.cs +++ b/aspnet-core/src/CoMon.Application/Assistant/AssistantAppService.cs @@ -34,6 +34,7 @@ public async Task GetRecommendations(long statusId) .Include(s => s.Package) .ThenInclude(s => s.Asset) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new EntityNotFoundException("Status not found."); @@ -58,6 +59,7 @@ public async Task GetAssetSummary(long assetId) .OrderByDescending(s => s.Time) .Take(1)) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new KeyNotFoundException("Asset not found."); var statuses = asset.Packages diff --git a/aspnet-core/src/CoMon.Application/Dashboards/DashboardAppService.cs b/aspnet-core/src/CoMon.Application/Dashboards/DashboardAppService.cs index 56977a1..4bd94f1 100644 --- a/aspnet-core/src/CoMon.Application/Dashboards/DashboardAppService.cs +++ b/aspnet-core/src/CoMon.Application/Dashboards/DashboardAppService.cs @@ -35,6 +35,7 @@ public async Task Get(long id) .Where(d => d.Id == id) .Include(d => d.Tiles) .AsSplitQuery() + .AsNoTracking() .SingleOrDefaultAsync() ?? throw new EntityNotFoundException("Dashboard not found for given id."); @@ -47,6 +48,7 @@ public async Task> GetAllPreviews() .GetAll() .Include(d => d.Tiles) .AsSplitQuery() + .AsNoTracking() .ToListAsync(); return dashboards.Select(d => new DashboardPreviewDto() diff --git a/aspnet-core/src/CoMon.Application/Groups/GroupAppService.cs b/aspnet-core/src/CoMon.Application/Groups/GroupAppService.cs index 5a00887..8fe65fe 100644 --- a/aspnet-core/src/CoMon.Application/Groups/GroupAppService.cs +++ b/aspnet-core/src/CoMon.Application/Groups/GroupAppService.cs @@ -54,6 +54,7 @@ public async Task Get(long id) .Include(g => g.SubGroups) .Include(g => g.Assets) .AsSplitQuery() + .AsNoTracking() .SingleOrDefaultAsync() ?? throw new EntityNotFoundException("Group not found."); @@ -74,6 +75,7 @@ public async Task GetPreview(long id) var group = await _groupRepository .GetAll() .Where(g => g.Id == id) + .AsNoTracking() .SingleOrDefaultAsync() ?? throw new EntityNotFoundException("Group not found."); @@ -93,6 +95,7 @@ public async Task> GetAllPreviews() .GetAll() .Include(g => g.Parent.Parent) .AsSplitQuery() + .AsNoTracking() .ToListAsync(); return _objectMapper.Map>(groups); diff --git a/aspnet-core/src/CoMon.Application/Groups/GroupAppServiceHelper.cs b/aspnet-core/src/CoMon.Application/Groups/GroupAppServiceHelper.cs index da92a16..5c6b2ee 100644 --- a/aspnet-core/src/CoMon.Application/Groups/GroupAppServiceHelper.cs +++ b/aspnet-core/src/CoMon.Application/Groups/GroupAppServiceHelper.cs @@ -23,6 +23,7 @@ public static async Task> GetLatestStatusesFromGroup(IRepository s.Time) .Take(1)) .AsSplitQuery() + .AsNoTracking() .SingleOrDefaultAsync() ?? throw new EntityNotFoundException("Group not found"); var statuses = group.Assets.Select(a => a.Packages).SelectMany(x => x).Select(p => p.Statuses).SelectMany(x => x).ToList(); @@ -56,6 +57,7 @@ public static async Task> GetAllLatestStatuses(IRepository s.Time) .Take(1)) .AsSplitQuery() + .AsNoTracking() .ToListAsync(); statuses.AddRange(assets.Select(a => a.Packages).SelectMany(x => x).Select(p => p.Statuses).SelectMany(x => x).ToList()); diff --git a/aspnet-core/src/CoMon.Application/Packages/PackageAppService.cs b/aspnet-core/src/CoMon.Application/Packages/PackageAppService.cs index 57dc0e8..f16bef4 100644 --- a/aspnet-core/src/CoMon.Application/Packages/PackageAppService.cs +++ b/aspnet-core/src/CoMon.Application/Packages/PackageAppService.cs @@ -35,6 +35,7 @@ await _packageRepository .Take(1)) .Where(p => p.Id == id) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new EntityNotFoundException("Package not found")); } @@ -48,6 +49,7 @@ await _packageRepository .ThenInclude(a => a.Group.Parent.Parent) .Where(p => p.Id == id) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new EntityNotFoundException("Package not found")); } diff --git a/aspnet-core/src/CoMon.Application/Statuses/StatusAppService.cs b/aspnet-core/src/CoMon.Application/Statuses/StatusAppService.cs index 6bf9f26..c6895ed 100644 --- a/aspnet-core/src/CoMon.Application/Statuses/StatusAppService.cs +++ b/aspnet-core/src/CoMon.Application/Statuses/StatusAppService.cs @@ -41,6 +41,7 @@ public async Task Get(long id) .ThenInclude(c => c.Series) .ThenInclude(s => s.DataPoints) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new EntityNotFoundException("Status not found."); @@ -84,6 +85,7 @@ public async Task GetPreview(long id) .ThenInclude(p => p.Asset) .ThenInclude(a => a.Group.Parent.Parent) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new EntityNotFoundException("Status not found."); status.IsLatest = await IsLatest(status); @@ -108,6 +110,7 @@ public async Task GetHistory(long id) .Include(s => s.Package) .Where(s => s.Id == id) .AsSplitQuery() + .AsNoTracking() .FirstOrDefaultAsync() ?? throw new EntityNotFoundException("Status not found."); @@ -115,6 +118,7 @@ public async Task GetHistory(long id) .GetAll() .Where(s => s.Package.Id == status.Package.Id) .OrderByDescending(s => s.Time) + .AsNoTracking() .FirstOrDefaultAsync(); if (latestStatus.Id == id) @@ -125,6 +129,7 @@ public async Task GetHistory(long id) .Where(s => s.Package.Id == status.Package.Id) .Where(s => s.Time < status.Time) .OrderByDescending(s => s.Time) + .AsNoTracking() .FirstOrDefaultAsync(); var nextStatus = await _statusRepository @@ -132,6 +137,7 @@ public async Task GetHistory(long id) .Where(s => s.Package.Id == status.Package.Id) .Where(s => s.Time > status.Time) .OrderBy(s => s.Time) + .AsNoTracking() .FirstOrDefaultAsync(); return new StatusHistoryDto() @@ -149,12 +155,14 @@ public async Task GetStatusTableOptions() .GetAll() .Include(a => a.Group.Parent.Parent) .AsSplitQuery() + .AsNoTracking() .ToListAsync(); var groups = await _groupRepository .GetAll() .Include(g => g.Parent.Parent) .AsSplitQuery() + .AsNoTracking() .ToListAsync(); return new StatusTableOptionsDto() @@ -218,6 +226,7 @@ public async Task> GetStatusTable(PagedResultRe .Skip(request.SkipCount) .Take(request.MaxResultCount) .AsSplitQuery() + .AsNoTracking() .ToList(); foreach (var status in statuses) @@ -241,6 +250,7 @@ public async Task GetLatestStatusPreview(long packageId) .OrderBy(p => p.Key.Name) .Select(g => g.OrderByDescending(s => s.Time).FirstOrDefault()) .AsSplitQuery() + .AsNoTracking() .SingleOrDefaultAsync(); return _objectMapper.Map(status);