From 1196a953362fc90cd766fc0cfede2920d17e8d82 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 11 Mar 2024 20:37:36 +0100 Subject: [PATCH] Materialize before returning data from GetAll calls --- src/Artemis.Storage/Repositories/DeviceRepository.cs | 2 +- src/Artemis.Storage/Repositories/EntryRepository.cs | 2 +- .../Repositories/Interfaces/IProfileCategoryRepository.cs | 3 +-- src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Artemis.Storage/Repositories/DeviceRepository.cs b/src/Artemis.Storage/Repositories/DeviceRepository.cs index 2eb7098c2..af3935161 100644 --- a/src/Artemis.Storage/Repositories/DeviceRepository.cs +++ b/src/Artemis.Storage/Repositories/DeviceRepository.cs @@ -31,7 +31,7 @@ internal class DeviceRepository(Func getContext) : IDeviceRepo public IEnumerable GetAll() { using ArtemisDbContext dbContext = getContext(); - return dbContext.Devices; + return dbContext.Devices.AsEnumerable(); } public void Save(DeviceEntity deviceEntity) diff --git a/src/Artemis.Storage/Repositories/EntryRepository.cs b/src/Artemis.Storage/Repositories/EntryRepository.cs index a901e637d..52bb8df7b 100644 --- a/src/Artemis.Storage/Repositories/EntryRepository.cs +++ b/src/Artemis.Storage/Repositories/EntryRepository.cs @@ -37,7 +37,7 @@ internal class EntryRepository(Func getContext) : IEntryReposi public IEnumerable GetAll() { using ArtemisDbContext dbContext = getContext(); - return dbContext.Entries; + return dbContext.Entries.AsEnumerable(); } public void Save(EntryEntity entryEntity) diff --git a/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs index 533e8990e..f2cb69f17 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using Artemis.Storage.Entities.Profile; namespace Artemis.Storage.Repositories.Interfaces; @@ -9,7 +8,7 @@ public interface IProfileCategoryRepository : IRepository { void Add(ProfileCategoryEntity profileCategoryEntity); void Remove(ProfileCategoryEntity profileCategoryEntity); - List GetAll(); + IEnumerable GetAll(); ProfileCategoryEntity? Get(Guid id); bool IsUnique(string name, Guid? id); void Save(ProfileCategoryEntity profileCategoryEntity); diff --git a/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs b/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs index 90e53c731..e1e58559e 100644 --- a/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs +++ b/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs @@ -25,7 +25,7 @@ internal class ProfileCategoryRepository(Func getContext, IPro dbContext.SaveChanges(); } - public List GetAll() + public IEnumerable GetAll() { if (!_migratedProfiles) { @@ -34,7 +34,7 @@ internal class ProfileCategoryRepository(Func getContext, IPro } using ArtemisDbContext dbContext = getContext(); - return dbContext.ProfileCategories.Include(c => c.ProfileConfigurations).ToList(); + return dbContext.ProfileCategories.Include(c => c.ProfileConfigurations).AsEnumerable(); } public ProfileCategoryEntity? Get(Guid id)