From 789fafe4c5245b83b8a7c7c3c67c15a20dcb7acf Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Tue, 18 Jul 2023 14:41:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=20?= =?UTF-8?q?=D1=82=D0=B8=D0=BF=20=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=B0=20Items=20=D1=83=20PaginationContainer=20=D0=BD=D0=B0=20?= =?UTF-8?q?IEnumerable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Data/PaginationContainer.cs | 14 +++----------- .../Repository/FileRepository.cs | 2 +- .../Repository/NotificationRepository.cs | 4 ++-- .../Repository/WellOperationRepository.cs | 2 +- .../Services/SAUB/MessageService.cs | 7 +++++-- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/AsbCloudApp/Data/PaginationContainer.cs b/AsbCloudApp/Data/PaginationContainer.cs index bdee31be..61840893 100644 --- a/AsbCloudApp/Data/PaginationContainer.cs +++ b/AsbCloudApp/Data/PaginationContainer.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; namespace AsbCloudApp.Data { @@ -13,16 +14,7 @@ namespace AsbCloudApp.Data /// public PaginationContainer() { - Items = new List(4); - } - - /// - /// конструктор - /// - /// - public PaginationContainer(int capacity) - { - Items = new List(capacity); + Items = Enumerable.Empty(); } /// @@ -43,6 +35,6 @@ namespace AsbCloudApp.Data /// /// Данные /// - public List Items { get; set; } + public IEnumerable Items { get; set; } } } diff --git a/AsbCloudInfrastructure/Repository/FileRepository.cs b/AsbCloudInfrastructure/Repository/FileRepository.cs index 7b078e10..e75e7691 100644 --- a/AsbCloudInfrastructure/Repository/FileRepository.cs +++ b/AsbCloudInfrastructure/Repository/FileRepository.cs @@ -111,7 +111,7 @@ namespace AsbCloudInfrastructure.Repository .ToListAsync(token) .ConfigureAwait(false); - result.Items = entities.Select(e => Convert(e)).ToList(); + result.Items = entities.Select(e => Convert(e)); return result; } diff --git a/AsbCloudInfrastructure/Repository/NotificationRepository.cs b/AsbCloudInfrastructure/Repository/NotificationRepository.cs index 90799208..8a44a418 100644 --- a/AsbCloudInfrastructure/Repository/NotificationRepository.cs +++ b/AsbCloudInfrastructure/Repository/NotificationRepository.cs @@ -70,14 +70,14 @@ public class NotificationRepository : CrudCacheRepositoryBase x.Adapt()) - .ToListAsync(cancellationToken); + .ToArrayAsync(cancellationToken); return result; } diff --git a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs index 00c87dbb..5d4795cb 100644 --- a/AsbCloudInfrastructure/Repository/WellOperationRepository.cs +++ b/AsbCloudInfrastructure/Repository/WellOperationRepository.cs @@ -165,7 +165,7 @@ namespace AsbCloudInfrastructure.Repository .Skip(result.Skip) .Take(result.Take); - result.Items = await query.ToListAsync(token); + result.Items = await query.ToArrayAsync(token); return result; } diff --git a/AsbCloudInfrastructure/Services/SAUB/MessageService.cs b/AsbCloudInfrastructure/Services/SAUB/MessageService.cs index 7b49d5c8..82f0abfc 100644 --- a/AsbCloudInfrastructure/Services/SAUB/MessageService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/MessageService.cs @@ -101,6 +101,8 @@ namespace AsbCloudInfrastructure.Services.SAUB var eventsDict = events.ToDictionary(x=>x.IdEvent, x => x); var usersDict = users.ToDictionary(x => x.IdUser, x => x); + var messagesDtoList = new List(); + foreach (var message in messagesList) { var messageDto = new MessageDto @@ -126,10 +128,11 @@ namespace AsbCloudInfrastructure.Services.SAUB messageDto.CategoryId = e.IdCategory; messageDto.Message = e.MakeMessageText(message); } - - result.Items.Add(messageDto); + messagesDtoList.Add(messageDto); } + result.Items = result.Items.Concat(messagesDtoList); + return result; }