2つの整数列のリストを選択しようとしていますが、結果をタプルにマップしています。結果をDapperのタプルにマップできますか?
return connection.Query<BogusClass>("select id1, id2 from sometable").ToList();
public class BogusClass{
public int id1 {get;set;}
public int id2 {get;set;}
}
私の好みは、いくつかの偽を作成する必要がないことである:ちょうど例として:私のような二つの整数を持つクラスを作成する場合
return connection.Query<Tuple<int,int>>("select id1, id2 from sometable").ToList();
は動作しませんが、同じクエリが動作しませんいくつかのデータを処理するためのクラスです。この場合、それは2つの整数列ですが、私が考えることができる他のユースケースがあります。
編集 - 回答: これはHTH
が変更私のために働いた構文は次のとおりです。
return connection.Query<Tuple<int,int>>("select id1, id2 from sometable").ToList();
へ:ここ
return connection.Query<int, int, Tuple<int, int>>("select id1, id2 from sometable", Tuple.Create, splitOn: "*").ToList();
ありがとうございましたVoid Ray、私はそれを働かせて、上記の答えを入れました(答えを編集するように編集されました) –