-
-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QuerySession.ForTenant disposal #2446
Comments
I attach some sample code with what I thought was correct code:
called with
throws |
The tenanted query session is internally cached and reused, so I think you should avoid disposing of the tenantSession, and instead rely on your DI disposing the scoped IQuerySession. If you want to keep disposing of sessions when you are done with them (which feels cleaner imo), what you can do is DI the IDocumentStore instead and call |
Ugh, don't call I'm pushing a quick fix to 6.0 right now that makes the dispose on |
We have a class with an
IQuerySession
injected in the constructor, and some methods that scope that session to a specific tenant with.ForTenant(tenant)
.We call some of the methods more than once, in the same scope.
As
ITenantQueryOperations
implementsIDisposable
, we were calling it withusing
. However, when doing that, the tenant session returned is the same instance that was already disposed.Looking into the code, I see the tenant session uses the same connection as the parent session, should we avoid disposing the sessions returned in
ForTenant
?The text was updated successfully, but these errors were encountered: