Executing following line of code:
conn.Update(CashInItem)
throws an exception:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM (line 465 in Contrib
var updated = connection.Execute(sb.ToString(), entityToUpdate, commandTimeout: commandTimeout, transaction: transaction);
)
I am testing Dapper.Contrib.
I have a table in SQL Server that has a few DateTime
columns - some of them allow NULL values.
I created an object with properties to match the columns in the table. For the DateTime
columns, the properties are nullable.
Here is an example of one of the properties:
public DateTime? ReconciledOn { get; set; }
I first use IDbConnection.Query
method to get a record from the SQL table. This runs OK and the object mapping is fine. When I check on of the nullable DateTime
values it shows null
.
I then, make a simple change to string parameter and call the following:
static bool Update(CashIn CashInItem)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString))
{
return conn.Update(CashInItem); //Error on this line
}
}
How can I fix this issue?