Skip to content

Commit 4e714b9

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
GH-5350: Add global setting for specifying the locale of the database.
1 parent a9afa4b commit 4e714b9

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/NHibernate/Cfg/Environment.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public static string Version
9292
/// <summary> A default database catalog name to use for unqualified tablenames</summary>
9393
public const string DefaultCatalog = "default_catalog";
9494

95+
public const string Locale = "locale";
96+
9597
// Since v5
9698
[Obsolete("DefaultEntityMode is deprecated.")]
9799
public const string DefaultEntityMode = "default_entity_mode";

src/NHibernate/Cfg/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Data;
4+
using System.Globalization;
45
using System.Linq.Expressions;
56
using NHibernate.AdoNet;
67
using NHibernate.AdoNet.Util;
@@ -228,5 +229,6 @@ internal string GetFullCacheRegionName(string name)
228229
public BatchFetchStyle BatchFetchStyle { get; internal set; }
229230
public BatchingEntityLoaderBuilder BatchingEntityLoaderBuilder { get; internal set; }
230231
public BatchingCollectionInitializerBuilder BatchingCollectionInitializationBuilder { get; internal set; }
232+
public CultureInfo Locale { get; internal set; }
231233
}
232234
}

src/NHibernate/Cfg/SettingsFactory.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Data;
5+
using System.Globalization;
56
using NHibernate.AdoNet;
67
using NHibernate.AdoNet.Util;
78
using NHibernate.Cache;
@@ -354,6 +355,9 @@ public Settings BuildSettings(IDictionary<string, string> properties)
354355
settings.BatchFetchStyle = PropertiesHelper.GetEnum(Environment.BatchFetchStyle, properties, BatchFetchStyle.Legacy);
355356
settings.BatchingEntityLoaderBuilder = GetBatchingEntityLoaderBuilder(settings.BatchFetchStyle);
356357
settings.BatchingCollectionInitializationBuilder = GetBatchingCollectionInitializationBuilder(settings.BatchFetchStyle);
358+
359+
string locale = PropertiesHelper.GetString(Environment.Locale, properties, CultureInfo.InvariantCulture.Name);
360+
settings.Locale = CultureInfo.GetCultureInfo(locale);
357361

358362
return settings;
359363
}

0 commit comments

Comments
 (0)