66using System . Data . SqlClient ;
77#endif
88using NHibernate . AdoNet ;
9+ using NHibernate . Dialect ;
910using NHibernate . Engine ;
1011using NHibernate . SqlTypes ;
1112
@@ -21,21 +22,41 @@ public class SqlClientDriver
2122 : ReflectionBasedDriver , IEmbeddedBatcherFactoryProvider
2223#endif
2324 {
25+ // Since v5.1
26+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForAnsiClob" ) ]
2427 public const int MaxSizeForAnsiClob = 2147483647 ; // int.MaxValue
28+ // Since v5.1
29+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForClob" ) ]
2530 public const int MaxSizeForClob = 1073741823 ; // int.MaxValue / 2
31+ // Since v5.1
32+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForBlob" ) ]
2633 public const int MaxSizeForBlob = 2147483647 ; // int.MaxValue
27- //http://stackoverflow.com/a/7264795/259946
34+
35+ ///<remarks>http://stackoverflow.com/a/7264795/259946</remarks>
36+ // Since v5.1
37+ [ Obsolete ( "Use MsSql2005Dialect.MaxSizeForXml" ) ]
2838 public const int MaxSizeForXml = 2147483647 ; // int.MaxValue
39+
40+ // Since v5.1
41+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForLengthLimitedAnsiString" ) ]
2942 public const int MaxSizeForLengthLimitedAnsiString = 8000 ;
43+ // Since v5.1
44+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForLengthLimitedString" ) ]
3045 public const int MaxSizeForLengthLimitedString = 4000 ;
46+ // Since v5.1
47+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForLengthLimitedBinary" ) ]
3148 public const int MaxSizeForLengthLimitedBinary = 8000 ;
3249 // Since v5.1
3350 [ Obsolete ( "This member has no more usages and will be removed in a future version" ) ]
3451 public const byte MaxPrecision = 28 ;
3552 // Since v5.1
3653 [ Obsolete ( "This member has no more usages and will be removed in a future version" ) ]
3754 public const byte MaxScale = 5 ;
55+ // Since v5.1
56+ [ Obsolete ( "Use MsSql2000Dialect.MaxDateTime2" ) ]
3857 public const byte MaxDateTime2 = 8 ;
58+ // Since v5.1
59+ [ Obsolete ( "Use MsSql2000Dialect.MaxDateTimeOffset" ) ]
3960 public const byte MaxDateTimeOffset = 10 ;
4061
4162 private Dialect . Dialect _dialect ;
@@ -139,10 +160,10 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
139160 {
140161 case DbType . AnsiString :
141162 case DbType . AnsiStringFixedLength :
142- dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MaxSizeForAnsiClob : MaxSizeForLengthLimitedAnsiString ;
163+ dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForAnsiClob : MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ;
143164 break ;
144165 case DbType . Binary :
145- dbParam . Size = IsBlob ( dbParam , sqlType ) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary ;
166+ dbParam . Size = IsBlob ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForBlob : MsSql2000Dialect . MaxSizeForLengthLimitedBinary ;
146167 break ;
147168 case DbType . Decimal :
148169 if ( _dialect == null )
@@ -152,16 +173,16 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
152173 break ;
153174 case DbType . String :
154175 case DbType . StringFixedLength :
155- dbParam . Size = IsText ( dbParam , sqlType ) ? MaxSizeForClob : MaxSizeForLengthLimitedString ;
176+ dbParam . Size = IsText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForClob : MsSql2000Dialect . MaxSizeForLengthLimitedString ;
156177 break ;
157178 case DbType . DateTime2 :
158- dbParam . Size = MaxDateTime2 ;
179+ dbParam . Size = MsSql2000Dialect . MaxDateTime2 ;
159180 break ;
160181 case DbType . DateTimeOffset :
161- dbParam . Size = MaxDateTimeOffset ;
182+ dbParam . Size = MsSql2000Dialect . MaxDateTimeOffset ;
162183 break ;
163184 case DbType . Xml :
164- dbParam . Size = MaxSizeForXml ;
185+ dbParam . Size = MsSql2005Dialect . MaxSizeForXml ;
165186 break ;
166187 }
167188
@@ -203,27 +224,27 @@ protected static void SetDefaultParameterSize(DbParameter dbParam, SqlType sqlTy
203224 {
204225 case DbType . AnsiString :
205226 case DbType . AnsiStringFixedLength :
206- dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MaxSizeForAnsiClob : MaxSizeForLengthLimitedAnsiString ;
227+ dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForAnsiClob : MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ;
207228 break ;
208229 case DbType . Binary :
209- dbParam . Size = IsBlob ( dbParam , sqlType ) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary ;
230+ dbParam . Size = IsBlob ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForBlob : MsSql2000Dialect . MaxSizeForLengthLimitedBinary ;
210231 break ;
211232 case DbType . Decimal :
212233 dbParam . Precision = MaxPrecision ;
213234 dbParam . Scale = MaxScale ;
214235 break ;
215236 case DbType . String :
216237 case DbType . StringFixedLength :
217- dbParam . Size = IsText ( dbParam , sqlType ) ? MaxSizeForClob : MaxSizeForLengthLimitedString ;
238+ dbParam . Size = IsText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForClob : MsSql2000Dialect . MaxSizeForLengthLimitedString ;
218239 break ;
219240 case DbType . DateTime2 :
220- dbParam . Size = MaxDateTime2 ;
241+ dbParam . Size = MsSql2000Dialect . MaxDateTime2 ;
221242 break ;
222243 case DbType . DateTimeOffset :
223- dbParam . Size = MaxDateTimeOffset ;
244+ dbParam . Size = MsSql2000Dialect . MaxDateTimeOffset ;
224245 break ;
225246 case DbType . Xml :
226- dbParam . Size = MaxSizeForXml ;
247+ dbParam . Size = MsSql2005Dialect . MaxSizeForXml ;
227248 break ;
228249 }
229250 }
@@ -236,7 +257,7 @@ protected static void SetDefaultParameterSize(DbParameter dbParam, SqlType sqlTy
236257 /// <returns>True, if the parameter should be interpreted as a Clob, otherwise False</returns>
237258 protected static bool IsAnsiText ( DbParameter dbParam , SqlType sqlType )
238259 {
239- return ( ( DbType . AnsiString == dbParam . DbType || DbType . AnsiStringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MaxSizeForLengthLimitedAnsiString ) ) ;
260+ return ( ( DbType . AnsiString == dbParam . DbType || DbType . AnsiStringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ) ) ;
240261 }
241262
242263 /// <summary>
@@ -247,7 +268,7 @@ protected static bool IsAnsiText(DbParameter dbParam, SqlType sqlType)
247268 /// <returns>True, if the parameter should be interpreted as a Clob, otherwise False</returns>
248269 protected static bool IsText ( DbParameter dbParam , SqlType sqlType )
249270 {
250- return ( sqlType is StringClobSqlType ) || ( ( DbType . String == dbParam . DbType || DbType . StringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MaxSizeForLengthLimitedString ) ) ;
271+ return ( sqlType is StringClobSqlType ) || ( ( DbType . String == dbParam . DbType || DbType . StringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedString ) ) ;
251272 }
252273
253274 /// <summary>
@@ -258,7 +279,7 @@ protected static bool IsText(DbParameter dbParam, SqlType sqlType)
258279 /// <returns>True, if the parameter should be interpreted as a Blob, otherwise False</returns>
259280 protected static bool IsBlob ( DbParameter dbParam , SqlType sqlType )
260281 {
261- return ( sqlType is BinaryBlobSqlType ) || ( ( DbType . Binary == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MaxSizeForLengthLimitedBinary ) ) ;
282+ return ( sqlType is BinaryBlobSqlType ) || ( ( DbType . Binary == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedBinary ) ) ;
262283 }
263284
264285
0 commit comments