forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqlDbTypeEx.cs
More file actions
51 lines (49 loc) · 4.04 KB
/
SqlDbTypeEx.cs
File metadata and controls
51 lines (49 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Simple.Data.SqlServer
{
using System.Data;
static class SqlDbTypeEx
{
private static readonly Dictionary<SqlDbType, Type> Map = new Dictionary<SqlDbType, Type>
{
{ SqlDbType.BigInt, typeof(long)},
{ SqlDbType.Binary, typeof(byte[]) },
{ SqlDbType.Bit, typeof(bool)},
{ SqlDbType.Char, typeof(string)},
{ SqlDbType.Date, typeof(DateTime)},
{ SqlDbType.DateTime, typeof(DateTime)},
{ SqlDbType.DateTime2, typeof(DateTime)},
{ SqlDbType.DateTimeOffset, typeof(DateTimeOffset)},
{ SqlDbType.Decimal, typeof(decimal)},
{ SqlDbType.Float, typeof(double)},
{ SqlDbType.Image, typeof(byte[])},
{ SqlDbType.Int, typeof(int)},
{ SqlDbType.Money, typeof(decimal) },
{SqlDbType.NChar, typeof(string)},
{ SqlDbType.NText, typeof(string)},
{ SqlDbType.NVarChar, typeof(string)},
{ SqlDbType.Real, typeof(Single)},
{ SqlDbType.SmallDateTime, typeof(DateTime)},
{ SqlDbType.SmallInt, typeof(short)},
{ SqlDbType.SmallMoney, typeof(decimal)},
{ SqlDbType.Structured, typeof(object)},
{ SqlDbType.Text, typeof(string)},
{ SqlDbType.Time, typeof(TimeSpan)},
{ SqlDbType.Timestamp, typeof(byte[])},
{ SqlDbType.TinyInt, typeof(byte)},
{ SqlDbType.Udt, typeof(object)},
{ SqlDbType.UniqueIdentifier, typeof(Guid)},
{ SqlDbType.VarBinary, typeof(byte[])},
{ SqlDbType.VarChar, typeof(string)},
{ SqlDbType.Variant, typeof(object)},
{ SqlDbType.Xml, typeof(string)}
};
public static Type ToClrType(this SqlDbType sqlDbType)
{
return Map[sqlDbType];
}
}
}