如何使用Dapper将一个或多个空列表传递给oracle查询?
基于此帖子https://stackoverflow.com/a/47552047/1462656的推荐
我的查询如下
public IEnumerable<Result> GetConcepts(List<string> types, List<string> sources)
{
using (var cnn = SimpleDbConnection())
{
cnn.Open();
int typesCount = types.Count;
int sourcesCount = sources.Count;
string query = @"SELECT mrconso.cui, mrconso.sab, mrsty.sty
from mrconso
inner join mrsty
on mrconso.cui = mrsty.cui ";
query += "WHERE :sourcesCount = 0 OR mrconso.SAB IN :sources AND :tCount= 0 OR mrsty.TUI IN :types";
return cnn.Query<Result>(query, new {tCount= typesCount, sourcesCount = sourcesCount, types = types, sources = sources });
}
}
但是我得到一个错误
“ ORA-00923:在预期位置找不到FROM关键字”
当我使用源列表为空列表执行查询时。 (当其中一个列表为空,并且两个列表都为空时,结果相同)