I have a table field(TotalPrice
) in our SQL Server 2016 database with numeric(20, 3)
data type.
I used ulong
type as my C# property type.
public ulong TotalPrice { get; set; }
When I want to insert a record in my Table the following exception occurred.
No mapping exists from DbType UInt64 to a known SqlDbType
My C# code to insert a record:
const string queryInsertInvoice = @"
INSERT INTO Invoice (CustomerId, Number, TotalPrice, LatestStatusDateTime)
VALUES (@CustomerId, @Number, @TotalPrice, @LatestStatusDateTime)
SELECT SCOPE_IDENTITY();";
var invoiceId = await dbConnection.QueryFirstOrDefaultAsync<int>(queryInsertInvoice, invoice);
How can I handle this situation with Dapper 2.0.53 ?
Just change TotalPrice type to decimal.
public decimal TotalPrice { get; set; }