-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataColumnSchema.cs
43 lines (36 loc) · 983 Bytes
/
DataColumnSchema.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CompleteSQL
{
public class DataColumnSchema
{
public readonly string Name;
public readonly Type Type;
public readonly bool AllowDbNull;
public DataColumnSchema(string columnName, Type type)
{
Name = columnName;
bool allowDbNull;
Type = ConvertType(type, out allowDbNull);
AllowDbNull = allowDbNull;
}
private Type ConvertType(Type type, out bool allowDbNull)
{
if (type != typeof(string))
{
allowDbNull = type.IsGenericType;
if (allowDbNull)
return type.GetGenericArguments()[0];
return type;
}
else
{
allowDbNull = true;
return type;
}
}
}
}