This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
src/ServiceStack.OrmLite.SqlServer/Converters Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Data ;
3
+ using System . Data . SqlClient ;
2
4
using ServiceStack . DataAnnotations ;
3
5
using ServiceStack . OrmLite . Converters ;
4
6
5
7
namespace ServiceStack . OrmLite . SqlServer . Converters
6
8
{
7
9
public class SqlServerStringConverter : StringConverter
8
10
{
9
- public override string MaxColumnDefinition
10
- {
11
- get { return UseUnicode ? "NVARCHAR(MAX)" : "VARCHAR(MAX)" ; }
12
- }
11
+ public override string MaxColumnDefinition => UseUnicode ? "NVARCHAR(MAX)" : "VARCHAR(MAX)" ;
13
12
14
13
public override string GetColumnDefinition ( int ? stringLength )
15
14
{
@@ -24,5 +23,18 @@ public override string GetColumnDefinition(int? stringLength)
24
23
? "NVARCHAR({0})" . Fmt ( safeLength )
25
24
: "VARCHAR({0})" . Fmt ( safeLength ) ;
26
25
}
26
+
27
+ public override void InitDbParam ( IDbDataParameter p , Type fieldType )
28
+ {
29
+ base . InitDbParam ( p , fieldType ) ;
30
+
31
+ var sqlParam = p as SqlParameter ;
32
+ if ( sqlParam == null ) return ;
33
+
34
+ if ( ! UseUnicode )
35
+ {
36
+ sqlParam . SqlDbType = SqlDbType . VarChar ;
37
+ }
38
+ }
27
39
}
28
40
}
You can’t perform that action at this time.
0 commit comments