【发布时间】:2020-08-22 01:10:24
【问题描述】:
我的 SQL Server 2016 数据库中有一个表字段 (TotalPrice),数据类型为 numeric(20, 3)。
我使用ulong 类型作为我的 C# 属性类型。
public ulong TotalPrice { get; set; }
当我想在我的表中插入一条记录时,发生了以下异常。
不存在从 DbType UInt64 到已知 SqlDbType 的映射
我的 C# 代码插入一条记录:
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);
如何使用 Dapper 2.0.53 处理这种情况?
【问题讨论】:
标签: c# sql-server dapper