是否可以在dapper中使用元组查询oracle?

时间:2016-01-19 11:11:52

标签: .net oracle dapper

在oracle中,您可以使用元组进行查询:

select Col1, Col2, Col3 from MyTable where (Col1, Col2) in ((1, 2), (3, 4))

现在,如果我使用Dapper,我应该为我的元组传递什么参数?

我试过了,但它不起作用:

var objs = conn.Query("select Col1, Col2, Col3 from MyTable where (Col1, Col2) in :arg", 
              new { arg = new List<Tuple<int, int>>()
                              {
                                Tuple.Create(1, 2), Tuple.Create(3, 4)
                              } }, null);

1 个答案:

答案 0 :(得分:-1)

要在这样的查询中使用元组,结果语法需要正确,因此对于Oracle,生成的解析查询字符串需要结束如下:

select Col1, Col2, Col3 from MyTable where (Col1, Col2) in ( (1,2),(3,4) );

老实说,我从来没有尝试过使用变量替换,而且我对Dapper不熟悉,但至少这会指向你想要的输出。例如,Dapper是否在输出列表周围放置了括号括号?