- 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.
47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
using DigitalData.Core.Abstractions.Infrastructure;
|
|
using DigitalData.Core.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using WorkFlow.Domain.Entities;
|
|
using WorkFlow.Infrastructure.Contracts;
|
|
|
|
namespace WorkFlow.Infrastructure.Repositories
|
|
{
|
|
public class ProfileObjStateRepository(WFDBContext dbContext) : CRUDRepository<ProfileObjState, int, WFDBContext>(dbContext, dbContext.ProfileObjStates), IProfileObjStateRepository, ICRUDRepository<ProfileObjState, int>
|
|
{
|
|
protected override IQueryable<ProfileObjState> ReadOnly() => base.ReadOnly().Include(pos => pos.Profile).Include(pos => pos.State);
|
|
|
|
protected IQueryable<ProfileObjState> 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;
|
|
}
|
|
}
|
|
} |