我刚刚在这里了解了QueryUnbufferedAsync
和IAsyncEnumerable
https://www.learndapper.com/dapper-query/selecting-unbuffered-async
并想在我自己的数据服务类中使用它,但我做错了事情,因为这不是编译.我想我搞砸了返回数据类型,但我想不出使用它的方法.
下面是我的代码:
private async Task<T> GetAsync2<T>(Func<DbConnection, Task<T>> operation)
{
if (operation is null) { throw new ArgumentNullException(nameof(operation)); }
await using DbConnection myCon = new SnowflakeDbConnection("myConnectionString");
await myCon.OpenAsync();
var result = await databaseOperation(myCon);
return result;
}
public async Task<IAsyncEnumerable<T>> GetAllAsync<T>(string sqlSelect) => await GetAsync2(conn => conn.QueryUnbufferedAsync<T>(sqlSelect));
This is the build error I get:
无法从使用情况推断方法"GetAsync 2(Func GbConnection,Task)"的类型参数