Can I map a result to Tuple in Dapper?

后端 未结 5 1321
梦谈多话
梦谈多话 2021-01-01 08:49

I am trying to select a list of 2 integer columns map the results to a Tuple. Just as an example:

return connection.Query>(\"sele         


        
5条回答
  •  时光说笑
    2021-01-01 09:26

    For those using async, this can be achieved by using ValueTuple.

    var res = await conn.QueryAsync<(int Id1, int Id2)>(sql);
    
    List> tuples = res.Select(x => new Tuple(x.Id1, x.Id2)).ToList();
    

提交回复
热议问题