c # Dapper-QueryAsync 메서드에서 linq 사용
Sep 01 2020
Query에서 제대로 작동하는데 왜 queryAsync에서 .select를 사용할 수 없습니까? 예를 들어, 여기에서 .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 열을 엔터티 속성에 매핑 하는 이전 질문을했습니다. " 'Select'기호를 확인할 수 없습니다."
답변
1 Milney Sep 01 2020 at 09:06
비동기 메서드는 작업 (기본적으로 비동기 작업의 최종 결과에 대한 자리 표시 자)을 반환합니다. 실제 가치를 얻으려면 기다려야합니다.
var result = (await sqlConnection.QueryAsync<Product>(
procedure,
commandType: CommandType.StoredProcedure
)).Select(p => new Product
{
Code= (string)p.fldCode,
Name=(string)p.fldName
}
);