I have a bigint
in my table and when I try to do a select using Dapper, it is not working. I found a tip that said to cast to numeric, but that is throwing a invalid cast error.
What is the correct cast to use with dapper?
Just type as 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; }
}