4
4
using System . Data . Common ;
5
5
using System . Data . SqlClient ;
6
6
using NHibernate . AdoNet ;
7
+ using NHibernate . Dialect ;
7
8
using NHibernate . Engine ;
8
9
using NHibernate . SqlTypes ;
9
10
@@ -14,21 +15,41 @@ namespace NHibernate.Driver
14
15
/// </summary>
15
16
public class SqlClientDriver : DriverBase , IEmbeddedBatcherFactoryProvider
16
17
{
18
+ // Since v5.1
19
+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForAnsiClob" ) ]
17
20
public const int MaxSizeForAnsiClob = 2147483647 ; // int.MaxValue
21
+ // Since v5.1
22
+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForClob" ) ]
18
23
public const int MaxSizeForClob = 1073741823 ; // int.MaxValue / 2
24
+ // Since v5.1
25
+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForBlob" ) ]
19
26
public const int MaxSizeForBlob = 2147483647 ; // int.MaxValue
20
- //http://stackoverflow.com/a/7264795/259946
27
+
28
+ ///<remarks>http://stackoverflow.com/a/7264795/259946</remarks>
29
+ // Since v5.1
30
+ [ Obsolete ( "Use MsSql2005Dialect.MaxSizeForXml" ) ]
21
31
public const int MaxSizeForXml = 2147483647 ; // int.MaxValue
32
+
33
+ // Since v5.1
34
+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForLengthLimitedAnsiString" ) ]
22
35
public const int MaxSizeForLengthLimitedAnsiString = 8000 ;
36
+ // Since v5.1
37
+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForLengthLimitedString" ) ]
23
38
public const int MaxSizeForLengthLimitedString = 4000 ;
39
+ // Since v5.1
40
+ [ Obsolete ( "Use MsSql2000Dialect.MaxSizeForLengthLimitedBinary" ) ]
24
41
public const int MaxSizeForLengthLimitedBinary = 8000 ;
25
42
// Since v5.1
26
43
[ Obsolete ( "This member has no more usages and will be removed in a future version" ) ]
27
44
public const byte MaxPrecision = 28 ;
28
45
// Since v5.1
29
46
[ Obsolete ( "This member has no more usages and will be removed in a future version" ) ]
30
47
public const byte MaxScale = 5 ;
48
+ // Since v5.1
49
+ [ Obsolete ( "Use MsSql2000Dialect.MaxDateTime2" ) ]
31
50
public const byte MaxDateTime2 = 8 ;
51
+ // Since v5.1
52
+ [ Obsolete ( "Use MsSql2000Dialect.MaxDateTimeOffset" ) ]
32
53
public const byte MaxDateTimeOffset = 10 ;
33
54
34
55
private Dialect . Dialect _dialect ;
@@ -117,10 +138,10 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
117
138
{
118
139
case DbType . AnsiString :
119
140
case DbType . AnsiStringFixedLength :
120
- dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MaxSizeForAnsiClob : MaxSizeForLengthLimitedAnsiString ;
141
+ dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForAnsiClob : MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ;
121
142
break ;
122
143
case DbType . Binary :
123
- dbParam . Size = IsBlob ( dbParam , sqlType ) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary ;
144
+ dbParam . Size = IsBlob ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForBlob : MsSql2000Dialect . MaxSizeForLengthLimitedBinary ;
124
145
break ;
125
146
case DbType . Decimal :
126
147
if ( _dialect == null )
@@ -130,16 +151,16 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
130
151
break ;
131
152
case DbType . String :
132
153
case DbType . StringFixedLength :
133
- dbParam . Size = IsText ( dbParam , sqlType ) ? MaxSizeForClob : MaxSizeForLengthLimitedString ;
154
+ dbParam . Size = IsText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForClob : MsSql2000Dialect . MaxSizeForLengthLimitedString ;
134
155
break ;
135
156
case DbType . DateTime2 :
136
- dbParam . Size = MaxDateTime2 ;
157
+ dbParam . Size = MsSql2000Dialect . MaxDateTime2 ;
137
158
break ;
138
159
case DbType . DateTimeOffset :
139
- dbParam . Size = MaxDateTimeOffset ;
160
+ dbParam . Size = MsSql2000Dialect . MaxDateTimeOffset ;
140
161
break ;
141
162
case DbType . Xml :
142
- dbParam . Size = MaxSizeForXml ;
163
+ dbParam . Size = MsSql2005Dialect . MaxSizeForXml ;
143
164
break ;
144
165
}
145
166
@@ -181,27 +202,27 @@ protected static void SetDefaultParameterSize(DbParameter dbParam, SqlType sqlTy
181
202
{
182
203
case DbType . AnsiString :
183
204
case DbType . AnsiStringFixedLength :
184
- dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MaxSizeForAnsiClob : MaxSizeForLengthLimitedAnsiString ;
205
+ dbParam . Size = IsAnsiText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForAnsiClob : MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ;
185
206
break ;
186
207
case DbType . Binary :
187
- dbParam . Size = IsBlob ( dbParam , sqlType ) ? MaxSizeForBlob : MaxSizeForLengthLimitedBinary ;
208
+ dbParam . Size = IsBlob ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForBlob : MsSql2000Dialect . MaxSizeForLengthLimitedBinary ;
188
209
break ;
189
210
case DbType . Decimal :
190
211
dbParam . Precision = MaxPrecision ;
191
212
dbParam . Scale = MaxScale ;
192
213
break ;
193
214
case DbType . String :
194
215
case DbType . StringFixedLength :
195
- dbParam . Size = IsText ( dbParam , sqlType ) ? MaxSizeForClob : MaxSizeForLengthLimitedString ;
216
+ dbParam . Size = IsText ( dbParam , sqlType ) ? MsSql2000Dialect . MaxSizeForClob : MsSql2000Dialect . MaxSizeForLengthLimitedString ;
196
217
break ;
197
218
case DbType . DateTime2 :
198
- dbParam . Size = MaxDateTime2 ;
219
+ dbParam . Size = MsSql2000Dialect . MaxDateTime2 ;
199
220
break ;
200
221
case DbType . DateTimeOffset :
201
- dbParam . Size = MaxDateTimeOffset ;
222
+ dbParam . Size = MsSql2000Dialect . MaxDateTimeOffset ;
202
223
break ;
203
224
case DbType . Xml :
204
- dbParam . Size = MaxSizeForXml ;
225
+ dbParam . Size = MsSql2005Dialect . MaxSizeForXml ;
205
226
break ;
206
227
}
207
228
}
@@ -214,7 +235,7 @@ protected static void SetDefaultParameterSize(DbParameter dbParam, SqlType sqlTy
214
235
/// <returns>True, if the parameter should be interpreted as a Clob, otherwise False</returns>
215
236
protected static bool IsAnsiText ( DbParameter dbParam , SqlType sqlType )
216
237
{
217
- return ( ( DbType . AnsiString == dbParam . DbType || DbType . AnsiStringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MaxSizeForLengthLimitedAnsiString ) ) ;
238
+ return ( ( DbType . AnsiString == dbParam . DbType || DbType . AnsiStringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedAnsiString ) ) ;
218
239
}
219
240
220
241
/// <summary>
@@ -225,7 +246,7 @@ protected static bool IsAnsiText(DbParameter dbParam, SqlType sqlType)
225
246
/// <returns>True, if the parameter should be interpreted as a Clob, otherwise False</returns>
226
247
protected static bool IsText ( DbParameter dbParam , SqlType sqlType )
227
248
{
228
- return ( sqlType is StringClobSqlType ) || ( ( DbType . String == dbParam . DbType || DbType . StringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MaxSizeForLengthLimitedString ) ) ;
249
+ return ( sqlType is StringClobSqlType ) || ( ( DbType . String == dbParam . DbType || DbType . StringFixedLength == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedString ) ) ;
229
250
}
230
251
231
252
/// <summary>
@@ -236,7 +257,7 @@ protected static bool IsText(DbParameter dbParam, SqlType sqlType)
236
257
/// <returns>True, if the parameter should be interpreted as a Blob, otherwise False</returns>
237
258
protected static bool IsBlob ( DbParameter dbParam , SqlType sqlType )
238
259
{
239
- return ( sqlType is BinaryBlobSqlType ) || ( ( DbType . Binary == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MaxSizeForLengthLimitedBinary ) ) ;
260
+ return ( sqlType is BinaryBlobSqlType ) || ( ( DbType . Binary == dbParam . DbType ) && sqlType . LengthDefined && ( sqlType . Length > MsSql2000Dialect . MaxSizeForLengthLimitedBinary ) ) ;
240
261
}
241
262
242
263
#region IEmbeddedBatcherFactoryProvider Members
0 commit comments