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