我的表中有一个bigint
,当我尝试使用Dapper进行选择时,它无法工作。我找到了一个提示说要转换为数字,但这会抛出无效的转换错误。
使用Dapper时,应该使用什么正确的转换方式?
我的表中有一个bigint
,当我尝试使用Dapper进行选择时,它无法工作。我找到了一个提示说要转换为数字,但这会抛出无效的转换错误。
使用Dapper时,应该使用什么正确的转换方式?
只需键入 long
即可:
public void TestNakedBigInt()
{
long foo = 12345;
var result = connection.Query<long>("select @foo", new {foo}).Single();
foo.IsEqualTo(result);
}
public void TestBigIntMember()
{
long foo = 12345;
var result = connection.Query<WithBigInt>(@"
declare @bar table(Value bigint)
insert @bar values (@foo)
select * from @bar", new {foo}).Single();
result.Value.IsEqualTo(foo);
}
class WithBigInt
{
public long Value { get; set; }
}