-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColumnInfo.cs
60 lines (56 loc) · 2.01 KB
/
ColumnInfo.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Data;
namespace CopyDb
{
class ColumnInfo
{
public readonly string Name;
public readonly SqlDbType Type;
public readonly int Size;
public readonly int Precision;
public readonly int Scale;
public readonly bool IsNullable;
public readonly bool IsIdentity;
public readonly int IdentitySeed;
public readonly int IdentityIncrement;
public readonly string Calculation;
public readonly int Position;
public readonly string Collation;
public bool IsDescending = false;
public ColumnInfo (string name, SqlDbType type, int size, int precision, int scale, bool isnullable, bool isidentity, int identityseed, int identityincr, string calculation, int position, string collation)
{
Name = name;
Type = type;
Size = size;
Precision = precision;
Scale = scale;
IsNullable = isnullable;
IsIdentity = isidentity;
IdentitySeed = identityseed;
IdentityIncrement = identityincr;
Calculation = calculation;
Position = position;
Collation = collation;
}
public ColumnInfo (object name, object type, object size, object precision, object scale, object isnullable, object isidentity, object identityseed, object identityincr, object calculation, object position, object collation)
: this(
(string) name,
(SqlDbType) Enum.Parse(typeof(SqlDbType), (string) type, true),
size.Equals(DBNull.Value)? -1: (int) size,
precision.Equals(DBNull.Value)? -1: (int) precision,
scale.Equals(DBNull.Value)? -1: (int) scale,
(bool) isnullable,
(bool) isidentity,
identityseed.Equals(DBNull.Value)? 0: (int) identityseed,
identityincr.Equals(DBNull.Value)? 0: (int) identityincr,
(calculation.Equals(DBNull.Value))? null: (string) calculation,
(int) position,
collation.Equals(DBNull.Value)? null: (string) collation
)
{}
public bool IsMaxSize
{
get { return Size == -1 && (Type == SqlDbType.NVarChar || Type == SqlDbType.VarBinary || Type == SqlDbType.VarChar); }
}
}
}