我通過設置我的.NET應用程序的語言環境:ASP.NET,SQL服務器,LINQTOSQL和日期格式
string userLocale = Web.Helpers.LocaleHelpers.GetBestRFC3066Locale(this.Context.Request.UserLanguages);
if (userLocale != String.Empty)
{
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(userLocale);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(userLocale);
}
這個效果很好,所以我的日期將根據區域設置顯示格式即
12/10/2009爲EN-GB 和 10/12/2009爲我們
然而,當我通過LinqToSql堅持我的日期,我需要這些日期存儲在一個共同的格式。
當前美國用戶正在運行該應用程序時,存儲在數據庫中的日期爲美國格式,並且當英國用戶使用該應用程序時,其格式爲英文。
關於如何最好地實現這一點的任何建議?