feat(repository): Abfragefunktionalität mit Filtern in ProfileControlsTFRepository hinzugefügt
- 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.
This commit is contained in:
parent
a7081d3f74
commit
845f7fe729
@ -1,5 +1,6 @@
|
|||||||
using DigitalData.Core.Abstractions.Infrastructure;
|
using DigitalData.Core.Abstractions.Infrastructure;
|
||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
|
|
||||||
@ -7,5 +8,29 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
{
|
{
|
||||||
public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository<ProfileControlsTF, int, WFDBContext>(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
public class ProfileControlsTFRepository(WFDBContext dbContext) : CRUDRepository<ProfileControlsTF, int, WFDBContext>(dbContext, dbContext.ProfileControlsTFs), IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
||||||
{
|
{
|
||||||
|
protected IQueryable<ProfileControlsTF> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user