Page 1 of 1

When Culture is set dates formatted incorectly

Posted: Wed 10 Feb 2016 17:41
by Bidorin
If the 'CurrentCulture' is set on the 'Thread' than the devart driver passes dates to the database in that culture. When a culture that uses a different date format than mysql than the database throws a date format is incorrect error. For example:

Code: Select all

string culture = "AR";
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

using (AuthContext context = new AuthContext())
{
	try
	{
		User user = await context.Users.SingleOrDefaultAsync(u => u.ID == userId);

		user.InterestedInReceivingCommunications = !user.InterestedInReceivingCommunications;
		user.ModifiedDate = DateTime.UtcNow;

		context.Users.Attach(user);
		context.Entry(user).State = EntityState.Modified;
		await context.SaveChangesAsync();
	}
	catch (Exception e)
	{
		Console.WriteLine(e);
	}
}
Is there a way to make the driver pass dates in a culture agnostic manner. I think this should be a bug because mysql requires a standard format for date storage. The driver should explicitly output in that format not whatever culture or format is set in the program.

Re: When Culture is set dates formatted incorectly

Posted: Thu 11 Feb 2016 14:47
by Shalex
We cannot reproduce the issue at the moment.

Please specify:
1) the exact text of the error and its full call stack with all inner exceptions
2) the default value of your CurrentCulture.Name
3) the versions of dotConnect for MySQL (x.x.x), MySQL Server (x.x.x), target .NET Framework of your project (x.x)
4) the character set and collation of your MySQL database