-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Unbuffered QueryAsnyc multi-mapping throws an InvalidOperationException #596
Comments
Figured out the cause. using (var reader = await ExecuteReaderWithFlagsFallbackAsync(cmd, wasClosed, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult, command.CancellationToken).ConfigureAwait(false))
{
if (!command.Buffered) wasClosed = false; // handing back open reader; rely on command-behavior
var results = MultiMapImpl<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(null, CommandDefinition.ForCallback(command.Parameters), map, splitOn, reader, identity, true);
return command.Buffered ? results.ToList() : results;
} I'll spin up a PR to fix. |
See DapperLib#596 for more detail. Originally, the code would dispose the dataReader that it opened before enumeration would begin. Now when you dispose the enumerator, it will also close the command, which is line with other behavior. Buffered behavior remains consistent. Has no impact on sync version.
Read about and use async/await Ex.: |
Any chance to get this patched? |
Please - Is there any way I can assist in resolving this? |
There isn't a change to be made here overall - a method using a connection and expected data needs to I'll cleanup this and the PR, but overall: when reading data, that needs to be completed before severing the connection to the data source. |
I agree with the OP that this is a Dapper bug, not a usage problem. Here's the source of Dapper/Dapper/SqlMapper.Async.cs Lines 912 to 915 in b452fb1
On line 912, a Thus, the IEnumerable state machine has a reference to a disposed The solution might be to transfer ownership of the |
@bgrainger Oh geez, I misread the example missing the |
Bump. Is there a reason @mburbea 's PR can't be merged? Is our only recourse to use the sync version? |
The call to Query returns
dog3
, the QueryAsync throws the following exception:The store procedure I am calling takes a while to execute and I'd rather let it be called async before I start streaming data out of the query.
The text was updated successfully, but these errors were encountered: