From 583866d75d74ff108584fbe5c633739ae444e37a Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Mon, 17 May 2021 14:04:33 +0500 Subject: [PATCH] =?UTF-8?q?CS2-1:=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B9=20=D0=BF=D0=B0=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=20=D0=B8=D0=B7=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=20GetDatesRange()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudDb/Model/AsbCloudDbContext.cs | 5 ++++- AsbCloudDb/Model/IAsbCloudDbContext.cs | 2 +- AsbCloudInfrastructure/Services/DataService.cs | 2 +- AsbCloudInfrastructure/Services/MessageService.cs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs index ab74e970..9fdbdc1d 100644 --- a/AsbCloudDb/Model/AsbCloudDbContext.cs +++ b/AsbCloudDb/Model/AsbCloudDbContext.cs @@ -195,8 +195,11 @@ namespace AsbCloudDb.Model .Include(e => e.Customer) .Where(e => e.Login == login); - public (DateTime From, DateTime To) GetDatesRange(DbSet dbSet, int idTelemetry) where T : class, IIdTelemetryDate + public (DateTime From, DateTime To) GetDatesRange(int idTelemetry) + where TEntity : class, IIdTelemetryDate { + var dbSet = Set(); + var datesRange = (from m in dbSet where m.IdTelemetry == idTelemetry group m by m.IdTelemetry into g diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs index da11c888..e7c46bca 100644 --- a/AsbCloudDb/Model/IAsbCloudDbContext.cs +++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs @@ -26,7 +26,7 @@ namespace AsbCloudDb.Model IQueryable GetWellsByCustomer(int idCustomer); IQueryable GetUsersByLogin(string login); - (DateTime From, DateTime To) GetDatesRange(DbSet dbSet, int idTelemetry) where T : class, IIdTelemetryDate; + (DateTime From, DateTime To) GetDatesRange(int idTelemetry) where T : class, IIdTelemetryDate; Task CreatePartitionAsync(string propertyName, int id, CancellationToken token = default) where TEntity : class; } } \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/DataService.cs b/AsbCloudInfrastructure/Services/DataService.cs index 323878d8..7a757025 100644 --- a/AsbCloudInfrastructure/Services/DataService.cs +++ b/AsbCloudInfrastructure/Services/DataService.cs @@ -102,7 +102,7 @@ namespace AsbCloudInfrastructure.Services if (telemetry is null) return null; - var result = db.GetDatesRange(db.DataSaubBases, telemetry.Id); + var result = db.GetDatesRange(telemetry.Id); return new DatesRangeDto { From = result.From, To = result.To}; } diff --git a/AsbCloudInfrastructure/Services/MessageService.cs b/AsbCloudInfrastructure/Services/MessageService.cs index 0d848e3c..477e59b3 100644 --- a/AsbCloudInfrastructure/Services/MessageService.cs +++ b/AsbCloudInfrastructure/Services/MessageService.cs @@ -108,7 +108,7 @@ namespace AsbCloudInfrastructure.Services if (telemetry is null) return null; - var result = db.GetDatesRange(db.Messages, telemetry.Id); + var result = db.GetDatesRange(telemetry.Id); return new DatesRangeDto { From = result.From, To = result.To }; }