From: <pa...@us...> - 2011-03-14 04:14:47
|
Revision: 5471 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5471&view=rev Author: patearl Date: 2011-03-14 04:14:41 +0000 (Mon, 14 Mar 2011) Log Message: ----------- Dialect method to get longest storage type for a specified DbType. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs trunk/nhibernate/src/NHibernate/Dialect/TypeNames.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2011-03-13 23:44:34 UTC (rev 5470) +++ trunk/nhibernate/src/NHibernate/Dialect/Dialect.cs 2011-03-14 04:14:41 UTC (rev 5471) @@ -449,6 +449,16 @@ return result; } + /// <summary> + /// Gets the name of the longest registered type for a particular DbType. + /// </summary> + /// <param name="dbType"></param> + /// <returns></returns> + public virtual string GetLongestTypeName(DbType dbType) + { + return typeNames.GetLongest(dbType); + } + /// <summary> /// Get the name of the database type appropriate for casting operations /// (via the CAST() SQL function) for the given <see cref="SqlType"/> typecode. Modified: trunk/nhibernate/src/NHibernate/Dialect/TypeNames.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/TypeNames.cs 2011-03-13 23:44:34 UTC (rev 5470) +++ trunk/nhibernate/src/NHibernate/Dialect/TypeNames.cs 2011-03-14 04:14:41 UTC (rev 5471) @@ -93,6 +93,23 @@ return Replace(Get(typecode), size, precision, scale); } + /// <summary> + /// For types with a simple length, this method returns the definition + /// for the longest registered type. + /// </summary> + /// <param name="typecode"></param> + /// <returns></returns> + public string GetLongest(DbType typecode) + { + SortedList<int, string> map; + weighted.TryGetValue(typecode, out map); + + if (map != null && map.Count > 0) + return Replace(map.Values[map.Count - 1], map.Keys[map.Count - 1], 0, 0); + + return Get(typecode); + } + private static string Replace(string type, int size, int precision, int scale) { type = StringHelper.ReplaceOnce(type, LengthPlaceHolder, size.ToString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |