diff --git a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs index 6e0d02d6..3c386136 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationService.cs @@ -106,7 +106,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService Take = take, Count = await query.CountAsync(token).ConfigureAwait(false), }; - var dateStart = query.Min(o => o.DateStart); + query = query .OrderBy(e => e.DateStart) .ThenBy(e => e.DepthEnd) @@ -118,8 +118,12 @@ namespace AsbCloudInfrastructure.Services.WellOperationService var entities = await query.Take(take).AsNoTracking() .ToListAsync(token).ConfigureAwait(false); + if (!entities.Any()) + return result; + var nptHours = 0d; + var dateStart = query.Min(o => o.DateStart); foreach (var entity in entities) { var dto = entity.Adapt(); @@ -287,8 +291,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService .Include(s => s.OperationCategory) .Where(s => s.IdWell == idWell); - var dateStart = query.Min(o => o.DateStart); - if (operationType.HasValue) query = query.Where(e => e.IdType == operationType.Value);