Interface IQueryGuardSessionAccessor
- Namespace
- QueryGuard
- Assembly
- QueryGuard.Core.dll
Provides the session that commands observed on the current asynchronous flow belong to.
public interface IQueryGuardSessionAccessor
Remarks
This interface exists because EF Core registers a DbCommandInterceptor as a
singleton. One interceptor instance sees commands from every concurrent
request, every parallel test, and every fan-out inside a single request. It therefore cannot
hold per-scope state: it has to ask where the command it is looking at belongs.
The default implementation is AsyncLocalQueryGuardSessionAccessor. Replacing it is supported for a host with a better propagation mechanism, but any replacement must guarantee the same thing: two concurrent flows never observe each other's session. Getting that wrong corrupts every number QueryGuard reports, and it fails intermittently: the worst possible failure mode for a tool whose whole purpose is to make test results trustworthy.
See docs/decisions/0002-session-propagation.md.
Properties
Methods
- Activate(QueryGuardSession)
Makes
sessioncurrent for the calling flow and everything it awaits.