From babddfff8389955e2cb249ff507208271ede47f0 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 12 Sep 2025 11:50:59 +0200 Subject: [PATCH] feat(DbRepository): add GetAll and GetAllAsync, make Where read-only - Updated Where() to use AsNoTracking() for read-only queries - Added GetAll() and GetAllAsync() to retrieve all entities - Improved repository methods for efficient read operations --- DigitalData.Core.Infrastructure/DbRepository.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DigitalData.Core.Infrastructure/DbRepository.cs b/DigitalData.Core.Infrastructure/DbRepository.cs index 679e5b1..62076bd 100644 --- a/DigitalData.Core.Infrastructure/DbRepository.cs +++ b/DigitalData.Core.Infrastructure/DbRepository.cs @@ -35,9 +35,11 @@ public class DbRepository : IRepository where TDbC return entities; } - public IQueryable Where(Expression> expression) => Entities.AsQueryable().Where(expression); + public IQueryable Where(Expression> expression) => Entities.AsNoTracking().Where(expression); - public IQueryable Get() => Entities.AsNoTracking(); + public IEnumerable GetAll() => Entities.AsNoTracking().ToList(); + + public async Task> GetAllAsync(CancellationToken cancel = default) => await Entities.AsNoTracking().ToListAsync(cancel); public virtual Task UpdateAsync(TDto dto, Expression> expression, CancellationToken cancel = default) => UpdateAsync(dto, q => q.Where(expression), cancel);