-
-
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
Add StreamAsync alternatives to support IAsyncEnumerable #1692
Conversation
Intentionally omitted cancellation tokens to keep the signatures similar. Since these are new I can include them. |
5256b4f
to
8fbb9b6
Compare
Re-authored commits (forgot to reset git config from a work account) |
Completes the "new IAsyncEnumerable API" task in V2 API refactors #1293 |
Will review when I'm back at in work-mode.
…On Mon, 3 Jan 2022, 15:33 David W. Francis, ***@***.***> wrote:
Completes the "new IAsyncEnumerable API" task #1293
<#1293>
—
Reply to this email directly, view it on GitHub
<#1692 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMHRAQOK5VG6UV36NKTUUG6U7ANCNFSM5BQFLJOQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@mgravell... Are you back from your sabbatical? 😅 @dwfrancis Thanks for the excellent work! I'm using the code in some non-production capacity (going into production next month) and so far it is going smoothly. 👍 |
I'm also waiting for that :D |
I was able to work around lack of support with the current stable version by using var reader = await connection.ExecuteReaderAsync(sql, param);
var rowParser = reader.GetRowParser<MyType>();
while (await reader.ReadAsync())
{
var value = rowParser(reader);
// Do other sync/async stuff with value.
yield return value;
} This also worked with |
Just wanted to also add my thanks to @dwfrancis for this PR. Combining this with System.Text.Json's newly introduced support for asynchronous Json serialization allows my API to return each row to the client as soon as they are retrieved from the database. |
It looks like a different implementation of what I did(#1882) as part of the solution #1239 (because in the comments to the issue it was #1239 (comment)). The fundamental difference is that I rewrote SqlMapper.Async and SqlMapper.GridReader.Async from pseudo-async to IAsyncEnumerable. And of course added "buffered" parameter. My point is that it might be worth choosing one of these two pull requests or considering them together. |
Any updates on that? 👀 |
No, Dapper seems to be abandoned. |
Add
StreamAsync
alternatives toconnecton.QueryAsync
andgridReader.ReadAsync
to supportIAsyncEnumerable
in a non-breaking way.Unlike
QueryAsync
, stream will default to unbuffered.