I am trying to select a list of 2 integer columns map the results to a Tuple. Just as an example:
return connection.Query<Tuple<int,int>>("select id1, id2 from sometable").ToList();
does not work, but the same query does work if I create a class with two integers such as:
return connection.Query<BogusClass>("select id1, id2 from sometable").ToList();
public class BogusClass{
public int id1 {get;set;}
public int id2 {get;set;}
}
My preference is not to have to create some bogus class just to get some data to work with. In this case it is two integer columns, but there are other use cases I could think of.
Edit - Answer:
This is the syntax that worked for me HTH
changed:
return connection.Query<Tuple<int,int>>("select id1, id2 from sometable").ToList();
to:
return connection.Query<int, int, Tuple<int, int>>("select id1, id2 from sometable", Tuple.Create, splitOn: "*").ToList();
question from:
https://stackoverflow.com/questions/34867432/can-i-map-a-result-to-tuple-in-dapper 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…