Created
September 12, 2023 21:46
-
-
Save jonsagara/7e7672870802192ea01d1fffaa95941a to your computer and use it in GitHub Desktop.
Dapper unbuffered query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sql = """ | |
SELECT | |
* | |
FROM | |
Widgets | |
WHERE | |
AccountId = @AccountId | |
ORDER BY | |
SomeField | |
"""; | |
using (var conn = new SqlConnection(config.GetConnectionString("MyConnectionString"))) | |
{ | |
await foreach (var widget in conn.QueryUnbufferedAsync<WidgetModel>(query, new { accountId })) | |
{ | |
// Do something with each record | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment