From 845f7fe729f45f0be06a3ecb29bf8d8bc4b5b207 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 23 Oct 2024 13:02:11 +0200 Subject: [PATCH] =?UTF-8?q?feat(repository):=20Abfragefunktionalit=C3=A4t?= =?UTF-8?q?=20mit=20Filtern=20in=20ProfileControlsTFRepository=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Methode `Read` mit optionalen Filtern für `Profile`, `User`, `profileId`, `usrId`, `objId` und `profileActive` in `ProfileControlsTFRepository` hinzugefügt. - `AsNoTracking` für schreibgeschützte Abfragen eingeführt. - `Include` für verwandte `Profile` und `User` Entitäten in der Abfrage hinzugefügt. --- .../ProfileControlsTFRepository.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs index e35acca..2b55db8 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs @@ -1,5 +1,6 @@ using DigitalData.Core.Abstractions.Infrastructure; using DigitalData.Core.Infrastructure; +using Microsoft.EntityFrameworkCore; using WorkFlow.Domain.Entities; using WorkFlow.Infrastructure.Contracts; @@ -7,5 +8,29 @@ namespace WorkFlow.Infrastructure.Repositories { public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository { + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = false, int? profileId = null, int? usrId = null, int? objId = null, bool? profileActive = null) + { + var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); + + if (withProfile) + query = query.Include(pctf => pctf.Profile); + + if (withUser) + query = query.Include(pctf => pctf.User); + + if (profileId is not null) + query = query.Where(pctf => pctf.ProfileId == profileId); + + if (usrId is not null) + query = query.Where(pctf => pctf.UsrId == usrId); + + if (objId is not null) + query = query.Where(pctf => pctf.ObjId == objId); + + if (profileActive is not null) + query = query.Where(pctf => pctf.Profile!.Active == profileActive); + + return query; + } } } \ No newline at end of file