public void Insert_Parameter_Dapper(DateTime?value) { using (var connection = GetConnection()) { var p = new DynamicParameters(); p.Add("@time_field", value, DbType.Time); connection.Execute("insert into [dbo].[insert_time_tests] (time_field) values (@time_field)", p); } DateTimeTestHelper.Insert_Parameter_VerifyResult(GetConnection, "insert_time_tests", "time_field", value); }
public void Insert_Parameter_ExecuteScalar_AseDbType(DateTime?value, string aseDbType, DateTime?expected) { using (var connection = GetConnection()) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "insert into [dbo].[insert_time_tests] (time_field) values (@time_field)"; var p = command.CreateParameter(); DateTimeTestHelper.SetAseDbType(p, aseDbType); p.ParameterName = "@time_field"; p.Value = (object)value ?? DBNull.Value; command.Parameters.Add(p); command.ExecuteNonQuery(); } } DateTimeTestHelper.Insert_Parameter_VerifyResult(GetConnection, "insert_time_tests", "time_field", expected); }