Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,9 @@ private IQueryable<TDocument> GetQueryableCollection(bool tenantAgnostic = false
{
var tenant = tenantAccessor.Tenant;
var tenantId = tenant?.Id.EmptyToNull();
queryable = queryable.Where(x => (x as Entity)!.TenantId == tenantId);
// Include tenant-agnostic ("*") rows so global entities (e.g. CLR workflow
// definitions) remain visible under a specific tenant, matching the EFCore provider.
queryable = queryable.Where(x => (x as Entity)!.TenantId == tenantId || (x as Entity)!.TenantId == Tenant.AgnosticTenantId);
}

return queryable;
Expand All @@ -448,7 +450,8 @@ private void ApplyTenantId(TDocument document)
var tenant = tenantAccessor.Tenant;
var tenantId = tenant?.Id;

if (document is Entity tenantDocument)
// Don't overwrite tenant-agnostic ("*") entities; only stamp tenant-specific ones.
if (document is Entity tenantDocument && tenantDocument.TenantId != Tenant.AgnosticTenantId)
tenantDocument.TenantId = tenantId.EmptyToNull();
}

Expand All @@ -459,7 +462,8 @@ private void ApplyTenantId(IEnumerable<TDocument> documents)

foreach (var document in documents)
{
if (document is Entity tenantDocument)
// Don't overwrite tenant-agnostic ("*") entities; only stamp tenant-specific ones.
if (document is Entity tenantDocument && tenantDocument.TenantId != Tenant.AgnosticTenantId)
tenantDocument.TenantId = tenantId.EmptyToNull();
}
}
Expand Down
Loading