Brief: I'm facing a problem with setting Global Query Filter using Claim added to signed user. Error scenario: when signing in ef core is still not loaded so
on first run. Is there any other way to set Global Query Filter to fix this problem? What I tried to do was sert query filter according to the user that sent the request. which works fine when I relaunch the application and happens again when the session ends and I log in again.
Brief: I'm facing a problem with setting Global Query Filter using Claim added to signed user. Error scenario: when signing in ef core is still not loaded so [code]OnModelCreating[/code] function is triggered that contains the configuration of my entities where I set Global Query Filter using tenant id claim using this function
[code] private long GetRequestTenantId() { try { var tenantClaim = contextAccessor.HttpContext.User.Claims.Where(c => c.Type == "TenantId").FirstOrDefault(); if (tenantClaim == null) return 0; bool IsParsed = long.TryParse(tenantClaim.Value, out long tenantId); if (!IsParsed) return 0; return tenantId; } catch (Exception ex) { return 0; } } [/code] which naturally return [code]0[/code] on first run. Is there any other way to set Global Query Filter to fix this problem? What I tried to do was sert query filter according to the user that sent the request. which works fine when I relaunch the application and happens again when the session ends and I log in again.