提交 bc344d0c 编写于 作者: S Sam Saffron

support for empty lists

上级 959b99e1
......@@ -375,10 +375,17 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
command.Parameters.Add(listParam);
}
command.CommandText = command.CommandText.Replace(namePrefix,
"(" + string.Join(
",", Enumerable.Range(1, count).Select(i => namePrefix + i.ToString())
) + ")");
if (count == 0)
{
command.CommandText = command.CommandText.Replace(namePrefix, "(SELECT NULL WHERE 1 = 0)");
}
else
{
command.CommandText = command.CommandText.Replace(namePrefix,
"(" + string.Join(
",", Enumerable.Range(1, count).Select(i => namePrefix + i.ToString())
) + ")");
}
}
}
......
......@@ -154,6 +154,9 @@ public void TestStringList()
{
connection.Query<string>("select * from (select 'a' as x union all select 'b' union all select 'c') as T where x in @strings", new {strings = new[] {"a","b","c"}})
.IsSequenceEqualTo(new[] {"a","b","c"});
connection.Query<string>("select * from (select 'a' as x union all select 'b' union all select 'c') as T where x in @strings", new { strings = new string[0] })
.IsSequenceEqualTo(new string[0]);
}
public void TestExecuteCommand()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册