Upgrade various store methods to IAsyncEnumerable
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user