From e1f0d611e5a6bc1f8ffc25f3aff93a7b4383c83b Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 23 Oct 2024 14:00:55 +0200 Subject: [PATCH] ProfileObjStateRepository mit Read-Methode erweitern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Neue Read-Methode zur ProfileObjStateRepository hinzugefügt, um flexiblere Abfragen zu ermöglichen. - Die Methode unterstützt optionale Parameter zur Filterung nach Profil, Benutzer, Zustand und Objekt-ID. - Verbesserte Datenabrufmöglichkeiten durch Einbeziehung verwandter Entitäten wie Profil und Zustand. --- .../ProfileControlsTFRepository.cs | 2 +- .../Repositories/ProfileObjStateRepository.cs | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs index 0941954..8442870 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileControlsTFRepository.cs @@ -10,7 +10,7 @@ namespace WorkFlow.Infrastructure.Repositories { protected override IQueryable ReadOnly() => base.ReadOnly().Include(pctf => pctf.Profile).Include(pctf => pctf.User); - protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = false, int? profileId = null, int? usrId = null, string? username = null, int? objId = null, bool? profileActive = null) + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, int? profileId = null, int? usrId = null, string? username = null, int? objId = null, bool? profileActive = null) { var query = isReadonly ? _dbSet.AsNoTracking() : _dbSet.AsQueryable(); diff --git a/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs b/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs index 849a75a..5d88fe0 100644 --- a/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs +++ b/WorkFlow.Infrastructure/Repositories/ProfileObjStateRepository.cs @@ -10,6 +10,38 @@ namespace WorkFlow.Infrastructure.Repositories { protected override IQueryable ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State); + protected IQueryable Read(bool isReadonly = false, bool withProfile = true, bool withUser = true, bool withState = true, int? profileId = null, int? usrId = null, string? username = null, int? stateId = 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 (withState) + query = query.Include(pctf => pctf.State); + + 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 (username is null) + query = query.Where(pctf => pctf.User!.Username == username); + + if (stateId is null) + query = query.Where(pctf => pctf.State!.Id == stateId); + + 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