I have this query below that reetives documents from a repo.
var kycDocs = await _kycDocRepo.GetAllAsync(a => a.CreatedBy == query.UserId &&
(query.Profile.Role == UserRoleName.Customer ? (a.Status == KYCDocumentStatus.Approved) :
a.Status != KYCDocumentStatus.UploadInProgress),
ignoreFilters: query.Profile.Role != UserRoleName.Customer,
select: a => new CustomerIdentityItemDTO
{
Id = a.Id,
Type = a.Type,
IdentityNumber = a.IdentityNumber,
IssuedOn = a.IssuedOn,
CreatedOn = a.CreatedOn,
ExpireOn = a.ExpireOn,
DocumentUrl = a.DocumentUrl,
Status = a.Status,
SubType = a.SubType,
ExpiryStatus = CustomerHelpers.GetDocumentValidityStatus(a.Type, a.ExpireOn)
});
this is the raw sql query
SET @__query_UserId_0 = 1214;
SELECT `k`.`Id`, `k`.`Type`, `k`.`IdentityNumber`, `k`.`IssuedOn`, `k`.`CreatedOn`, `k`.`ExpireOn`, `k`.`DocumentUrl`, `k`.`Status`, `k`.`SubType`
FROM `KYCDocument` AS `k`
WHERE NOT (`k`.`IsDeleted`) AND ((`k`.`CreatedBy` = @__query_UserId_0) AND (`k`.`Status` <> -1))
This global query filter is set on the AuditableEntity that the kycDocRepo inherits from
builder.HasQueryFilter(a => !a.IsDeleted);
I am to display all documents both deleted except the ones where the status are UploadInProgress to users that are not customers basically admins.
The major issue is that the ignoreFilters is not been executed.
Also i had tried some other approaches which only added another where clause Where K is Deleted.
What i want to do is to ignore the query filters and display the deleted documents
I have tried this just to see if the query filter will be ignored
var kycDocs = await _kycDocRepo.GetAllAsync(a => a.CreatedBy == query.UserId &&
(query.Profile.Role == UserRoleName.Customer ? (a.Status == KYCDocumentStatus.Approved) : true),
ignoreFilters: ignoreQueryFilters,
select: a => new CustomerIdentityItemDTO
{
Id = a.Id,
Type = a.Type,
IdentityNumber = a.IdentityNumber,
IssuedOn = a.IssuedOn,
CreatedOn = a.CreatedOn,
ExpireOn = a.ExpireOn,
DocumentUrl = a.DocumentUrl,
Status = a.Status,
SubType = a.SubType,
ExpiryStatus = CustomerHelpers.GetDocumentValidityStatus(a.Type, a.ExpireOn)
});