c# Dapper - 在 QueryAsync 方法上使用 linq
c# Dapper - using linq on QueryAsync method
为什么我不能在 queryAsync 上使用 .select,而它在 Query 上运行良好?
例如,这里 .select 对我大喊大叫,告诉我它无法解析符号 "select":
var result = await sqlConnection.QueryAsync<Product>(procedure,
commandType: CommandType.StoredProcedure).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
});
但是我一换成Query,它就不喊了。如果有的话,它无法从 sp:
解析 fldCode 列
var result = sqlConnection.Query<Product>(procedure,
commandType: CommandType.StoredProcedure).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
});
这是为什么?
我在这里问了一个问题 C# Dapper mapping columns to entity properties - "Cannot resolve symbol 'Select'"
异步方法 return 任务(基本上是异步操作最终结果的占位符)。您需要等待它才能获得实际值
var result = (await sqlConnection.QueryAsync<Product>(
procedure,
commandType: CommandType.StoredProcedure
)).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
}
);
为什么我不能在 queryAsync 上使用 .select,而它在 Query 上运行良好? 例如,这里 .select 对我大喊大叫,告诉我它无法解析符号 "select":
var result = await sqlConnection.QueryAsync<Product>(procedure,
commandType: CommandType.StoredProcedure).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
});
但是我一换成Query,它就不喊了。如果有的话,它无法从 sp:
解析 fldCode 列 var result = sqlConnection.Query<Product>(procedure,
commandType: CommandType.StoredProcedure).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
});
这是为什么?
我在这里问了一个问题 C# Dapper mapping columns to entity properties - "Cannot resolve symbol 'Select'"
异步方法 return 任务(基本上是异步操作最终结果的占位符)。您需要等待它才能获得实际值
var result = (await sqlConnection.QueryAsync<Product>(
procedure,
commandType: CommandType.StoredProcedure
)).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
}
);