我试图用小巧玲珑来传递一个布尔值作为参数传递给甲骨文,翻译成1/0场的数据库上,像这样:使用通C#布尔作为参数传递给甲骨文小巧玲珑
public class Customer
{
public bool Active { get; set; }
}
static void InsertCustomer()
{
var customer = connect.QueryFirst<Customer>("select 1 active from dual"); // this works
connect.Execute("insert into customers(active) values(:active)", customer); // this doesn't
}
但这会引发异常:
System.ArgumentException:'值不在预期的 范围内。
我知道我可以创建另一个属性public int ActiveInt => Active ? 1 : 2;
,但我想保持我的POCO类尽可能干净,特别是因为性需要是公众小巧玲珑使用它们作为参数。
我试图创建一个布尔类型的处理程序,但它仅适用于查询栏,没有参数:https://github.com/StackExchange/Dapper/issues/303
我还需要通过整个对象作为参数,传递参数时,所以转换是不可能的。
有没有办法做到这一点?