When Culture is set dates formatted incorectly

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Bidorin
Posts: 1
Joined: Wed 10 Feb 2016 17:17

When Culture is set dates formatted incorectly

Post by Bidorin » Wed 10 Feb 2016 17:41

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: When Culture is set dates formatted incorectly

Post by Shalex » Thu 11 Feb 2016 14:47

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

Post Reply