SqlFormatter and non-English culture

May 21, 2012 at 2:21 PM
Edited May 21, 2012 at 2:22 PM

Please fix SqlProvider to write floating point constant values using InvariantCulture.

DateTime constants should be passed in XML format to prevent inconsistency in .NET Thread.CurrentCulture and VFP SET DATE setting

WriteValue() method:

TypeCode.Single: case TypeCode.Double: case TypeCode.Decimal: string str = string.Format(CultureInfo.InvariantCulture, "{0}", value); if (!str.Contains('.')) { str += ".0"; } this.Write(str); break; case TypeCode.DateTime: this.Write(string.Format("CTOT('{0:yyyy-MM-dd}T{0:HH:mm:ss}')", value)); break;
May 22, 2012 at 3:10 PM

I’d like to setup a test and see the failure prior to modifying the code. Do you have a code example that would execute this code path? Also, the code looks like you pulled if from the LINQ to VFP project. Was this code change intended for that project?

May 23, 2012 at 11:37 AM

>>Also, the code looks like you pulled if from the LINQ to VFP project

No, it's in VfpEntityFrameworkProvider.Visitors.SqlFormatter class, WriteValue() method.

Test case for this issue:

using System.Globalization;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace VfpEntityFrameworkProvider.Tests
    public class NonEnglishCultureTests: TestBase 
        public void InitCulture()
            Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");

        public void DecimalInsertTest()
            DecimalEntities dec = new DecimalEntities();
            dec.Decimaltables.AddObject(new Decimaltable()
                Ivalue = 2.3456M

May 24, 2012 at 12:41 AM

Thanks for helping me with this localization issue.  I posted a build that includes your code changes.