Hello.
I always get ObjectDisposedException when execute same query on differend instances of dbContext. Firs execution is succesfull but second execution on different instance of dbContext fails with ObjectDisposedException:
System.ObjectDisposedException : Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
The problem seems to be in last changes of `MongoDbDatabase.CompileAsyncQuery()' method:
public override Func<QueryContext, IAsyncEnumerable<TResult>> CompileAsyncQuery<TResult>(QueryModel queryModel)
=> queryContext => CompileQuery<TResult>(queryModel)(queryContext).ToAsyncEnumerable();
I think the problem in above code is CompileQuery<TResult>(queryModel) executes within lambda and queryModel have been disposed some way on second query execution.
When I revert previous version of this method iisue disappears:
public override Func<QueryContext, IAsyncEnumerable<TResult>> CompileAsyncQuery<TResult>(QueryModel queryModel)
{
var syncQueryExecutor = CompileQuery<TResult>(queryModel);
return qc => syncQueryExecutor(qc).ToAsyncEnumerable();
}
Hello. I always get ObjectDisposedException when execute same query on differend instances of dbContext. Firs execution is succesfull but second execution on different instance of dbContext fails with ObjectDisposedException:
System.ObjectDisposedException : Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Here the test case to reproduse this issue:
The problem seems to be in last changes of `MongoDbDatabase.CompileAsyncQuery()' method:
I think the problem in above code is
CompileQuery<TResult>(queryModel)
executes within lambda andqueryModel
have been disposed some way on second query execution.When I revert previous version of this method iisue disappears:
related to this comment in another issue: https://github.com/BlueshiftSoftware/EntityFrameworkCore/issues/29#issuecomment-444771018