forked from olejorgensen/CompactView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InformationSchema.Column.cs
188 lines (143 loc) · 5.78 KB
/
InformationSchema.Column.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**************************************************************************
Copyright (C) 2023 Rekkonnect
This file is part of CompactView.
CompactView is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CompactView is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CompactView. If not, see <http://www.gnu.org/licenses/>.
CompactView web site <http://sourceforge.net/p/compactview/>.
**************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace CompactView
{
public partial class InformationSchema
{
[Table("COLUMNS", Schema = Schema)]
public class Column
{
[Key]
[Column("TABLE_NAME", Order = 0)]
public string TableName { get; set; }
[Key]
[Column("COLUMN_NAME", Order = 1)]
public string ColumnName { get; set; }
[Column("COLUMN_HASDEFAULT")]
public bool HasDefaultValue { get; set; }
[Column("COLUMN_DEFAULT")]
public string DefaultValue { get; set; }
[Column("ORDINAL_POSITION")]
public int OrdinalPosition { get; set; }
[Column("IS_NULLABLE")]
public string IsNullableName { get; set; }
[Column("DATA_TYPE")]
public string DataType { get; set; }
[Column("CHARACTER_MAXIMUM_LENGTH")]
public int? CharacterMaximumLength { get; set; }
[Column("NUMERIC_PRECISION")]
public int? NumericPrecision { get; set; }
[Column("NUMERIC_SCALE")]
public int? NumericScale { get; set; }
[Column("AUTOINC_SEED")]
public long? AutoIncrementSeed { get; set; }
[Column("AUTOINC_INCREMENT")]
public long? AutoIncrementBy { get; set; }
#region Ignored
[NotMapped]
[Column("TABLE_CATALOG")]
public string TableCatalog { get; set; }
[NotMapped]
[Column("TABLE_SCHEMA")]
public string TableSchema { get; set; }
[NotMapped]
[Column("COLUMN_GUID")]
public string ColumnGuid { get; set; }
[NotMapped]
[Column("COLUMN_PROPID")]
public string ColumnPropid { get; set; }
[NotMapped]
[Column("COLUMN_FLAGS")]
public int ColumnFlags { get; set; }
[NotMapped]
[Column("TYPE_GUID")]
public string TypeGuid { get; set; }
[NotMapped]
[Column("CHARACTER_OCTET_LENGTH")]
public int CharacterOctetLength { get; set; }
[NotMapped]
[Column("DATETIME_PRECISION")]
public string DatetimePrecision { get; set; }
[NotMapped]
[Column("CHARACTER_SET_CATALOG")]
public string CharacterSetCatalog { get; set; }
[NotMapped]
[Column("CHARACTER_SET_SCHEMA")]
public string CharacterSetSchema { get; set; }
[NotMapped]
[Column("CHARACTER_SET_NAME")]
public string CharacterSetName { get; set; }
[NotMapped]
[Column("COLLATION_CATALOG")]
public string CollationCatalog { get; set; }
[NotMapped]
[Column("COLLATION_SCHEMA")]
public string CollationSchema { get; set; }
[NotMapped]
[Column("COLLATION_NAME")]
public string CollationName { get; set; }
[NotMapped]
[Column("DOMAIN_CATALOG")]
public string DomainCatalog { get; set; }
[NotMapped]
[Column("DOMAIN_SCHEMA")]
public string DomainSchema { get; set; }
[NotMapped]
[Column("DOMAIN_NAME")]
public string DomainName { get; set; }
[NotMapped]
[Column("DESCRIPTION")]
public string Description { get; set; }
[NotMapped]
[Column("AUTOINC_MIN")]
public int AutoIncrementMin { get; set; }
[NotMapped]
[Column("AUTOINC_MAX")]
public int AutoIncrementMax { get; set; }
[NotMapped]
[Column("AUTOINC_NEXT")]
public int AutoIncrementNext { get; set; }
#endregion
[NotMapped]
public bool IsNullable => IsNullableName.Equals("YES",
StringComparison.OrdinalIgnoreCase);
[NotMapped]
public bool IsRowGuidCol => KnownColumnFlags.IsRowGuidCol(ColumnFlags);
public static class KnownColumnFlags
{
public const int RowGuidColA = 378;
public const int RowGuidColB = 282;
public static bool IsRowGuidCol(int flags)
{
return flags is RowGuidColA
|| flags is RowGuidColB;
}
}
public sealed class OrdinalComparer : IComparer<Column>
{
public static OrdinalComparer Instance { get; } = new OrdinalComparer();
public int Compare(Column x, Column y)
{
return x.OrdinalPosition.CompareTo(y.OrdinalPosition);
}
}
}
}
}