我正在尝试执行以下操作:
var p = new DynamicParameters();
p.Add(...);
p.Add(...);
// ideally I want to insert null for end date, but I also tried DateTime.MinValue
// or some other date, but doesn't help
p.Add("@endDate", null, DbType.DateTime, ParameterDirection.Input);
using (var con = new SqlConnection(ConnectionString))
{
// stored procedure does 'select SCOPE_IDENTITY()' to return the id of inserted row.
int id = con.Query<int>("StoredProcedureName", p, commandType: CommandType.StoredProcedure).First();
}
这是抛出“InvalidCastException”,我相信这是因为日期。我以前在 sql db 中有 endDate 的 datetime2(20) ,将其更改为 datetime 以查看它是否修复它,但没有。任何人都可以帮忙吗?