mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-07 14:27:54 +00:00
Upgrade various store methods to IAsyncEnumerable
This commit is contained in:
parent
9a3355eb4b
commit
8a689ac0f2
7 changed files with 62 additions and 38 deletions
|
|
@ -669,4 +669,17 @@ namespace PluralKit
|
|||
EventId = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConnectionUtils
|
||||
{
|
||||
public static async IAsyncEnumerable<T> QueryStreamAsync<T>(this DbConnectionFactory connFactory, string sql, object param)
|
||||
{
|
||||
using var conn = await connFactory.Obtain();
|
||||
|
||||
var reader = await conn.ExecuteReaderAsync(sql, param);
|
||||
var parser = reader.GetRowParser<T>();
|
||||
while (reader.Read())
|
||||
yield return parser(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue