I am in the process of upgrading from v4.0.36 to v4.0.46 and I'm getting issues where the SQL that is generated through this API doesn't convert the DateTime values correctly:
public static List<T> SqlList<T> (this IDbConnection dbConn, string sql, object anonType = null);
The DateTime would be an attribute as part of object passed through to the method.
When on v4.0.36 the DateTime value would result in the string "yyyy-MM-dd HH:mm:ss"
However after upgrading to v4.0.46 the DateTime value is now "dd/MM/yyyy HH:mm:ss AM"
and because of this queries that rely on a date are now not returning any records because MySQL doesn't recognise this format.
Is there a config I'm missing? Or any pointers on what changes I need to make to get the same behaviour as 4.0.36?
This should now be resolved from this commit, available from v4.0.47 that's now available on MyGet which supports each of the call styles below:
class DateTest
{
public DateTime Test { get; set; }
public DateTime? TestNullable { get; set; }
}
using (var db = OpenDbConnection())
{
db.DropAndCreateTable<DateTest>();
var dateTime = new DateTime(2001, 1, 1, 1, 1, 1);
db.Insert(new DateTest{ Test = dateTime, TestNullable = dateTime });
var row = db.SqlList<DateTest>(
"SELECT * FROM DateTest WHERE Test = @dateTime"), new { dateTime });
row = db.SqlList<DateTest>(
"SELECT * FROM DateTest WHERE TestNullable = @dateTime"), new { dateTime });
DateTime? nullDate = dateTime;
row = db.SqlList<DateTest>(
"SELECT * FROM DateTest WHERE TestNullable = @nullDate"), new { nullDate });
}