/
NpgsqlDbColumn.cs
235 lines (200 loc) · 6.75 KB
/
NpgsqlDbColumn.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
using System;
using System.Data.Common;
using System.Runtime.CompilerServices;
using Npgsql.PostgresTypes;
using NpgsqlTypes;
namespace Npgsql.Schema;
/// <summary>
/// Provides schema information about a column.
/// </summary>
/// <remarks>
/// Note that this can correspond to a field returned in a query which isn't an actual table column
///
/// See https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getschematable(v=vs.110).aspx
/// for information on the meaning of the different fields.
/// </remarks>
public class NpgsqlDbColumn : DbColumn
{
/// <summary>
/// Initializes a new instance of the <see cref="NpgsqlDbColumn" /> class.
/// </summary>
public NpgsqlDbColumn()
{
PostgresType = UnknownBackendType.Instance;
// Not supported in PostgreSQL
IsExpression = false;
IsAliased = false;
IsHidden = false;
IsIdentity = false;
}
internal NpgsqlDbColumn Clone() =>
Unsafe.As<NpgsqlDbColumn>(MemberwiseClone());
#region Standard fields
// ReSharper disable once InconsistentNaming
/// <inheritdoc cref="DbColumn.AllowDBNull" />
public new bool? AllowDBNull
{
get => base.AllowDBNull;
protected internal set => base.AllowDBNull = value;
}
/// <inheritdoc cref="DbColumn.BaseCatalogName" />
public new string BaseCatalogName
{
get => base.BaseCatalogName!;
protected internal set => base.BaseCatalogName = value;
}
/// <inheritdoc cref="DbColumn.BaseColumnName" />
public new string? BaseColumnName
{
get => base.BaseColumnName;
protected internal set => base.BaseColumnName = value;
}
/// <inheritdoc cref="DbColumn.BaseSchemaName" />
public new string? BaseSchemaName
{
get => base.BaseSchemaName;
protected internal set => base.BaseSchemaName = value;
}
/// <inheritdoc cref="DbColumn.BaseServerName" />
public new string BaseServerName
{
get => base.BaseServerName!;
protected internal set => base.BaseServerName = value;
}
/// <inheritdoc cref="DbColumn.BaseTableName" />
public new string? BaseTableName
{
get => base.BaseTableName;
protected internal set => base.BaseTableName = value;
}
/// <inheritdoc cref="DbColumn.ColumnName" />
public new string ColumnName
{
get => base.ColumnName;
protected internal set => base.ColumnName = value;
}
/// <inheritdoc cref="DbColumn.ColumnOrdinal" />
public new int? ColumnOrdinal
{
get => base.ColumnOrdinal;
protected internal set => base.ColumnOrdinal = value;
}
/// <inheritdoc cref="DbColumn.ColumnSize" />
public new int? ColumnSize
{
get => base.ColumnSize;
protected internal set => base.ColumnSize = value;
}
/// <inheritdoc cref="DbColumn.IsAliased" />
public new bool? IsAliased
{
get => base.IsAliased;
protected internal set => base.IsAliased = value;
}
/// <inheritdoc cref="DbColumn.IsAutoIncrement" />
public new bool? IsAutoIncrement
{
get => base.IsAutoIncrement;
protected internal set => base.IsAutoIncrement = value;
}
/// <inheritdoc cref="DbColumn.IsIdentity" />
public new bool? IsIdentity
{
get => base.IsIdentity;
protected internal set => base.IsIdentity = value;
}
/// <inheritdoc cref="DbColumn.IsKey" />
public new bool? IsKey
{
get => base.IsKey;
protected internal set => base.IsKey = value;
}
/// <inheritdoc cref="DbColumn.IsLong" />
public new bool? IsLong
{
get => base.IsLong;
protected internal set => base.IsLong = value;
}
/// <inheritdoc cref="DbColumn.IsReadOnly" />
public new bool? IsReadOnly
{
get => base.IsReadOnly;
protected internal set => base.IsReadOnly = value;
}
/// <inheritdoc cref="DbColumn.IsUnique" />
public new bool? IsUnique
{
get => base.IsUnique;
protected internal set => base.IsUnique = value;
}
/// <inheritdoc cref="DbColumn.NumericPrecision" />
public new int? NumericPrecision
{
get => base.NumericPrecision;
protected internal set => base.NumericPrecision = value;
}
/// <inheritdoc cref="DbColumn.NumericScale" />
public new int? NumericScale
{
get => base.NumericScale;
protected internal set => base.NumericScale = value;
}
/// <inheritdoc cref="DbColumn.UdtAssemblyQualifiedName" />
public new string? UdtAssemblyQualifiedName
{
get => base.UdtAssemblyQualifiedName;
protected internal set => base.UdtAssemblyQualifiedName = value;
}
/// <inheritdoc cref="DbColumn.DataType" />
public new Type? DataType
{
get => base.DataType;
protected internal set => base.DataType = value;
}
/// <inheritdoc cref="DbColumn.DataTypeName" />
public new string DataTypeName
{
get => base.DataTypeName!;
protected internal set => base.DataTypeName = value;
}
#endregion Standard fields
#region Npgsql-specific fields
/// <summary>
/// The <see cref="PostgresType" /> describing the type of this column.
/// </summary>
public PostgresType PostgresType { get; internal set; }
/// <summary>
/// The OID of the type of this column in the PostgreSQL pg_type catalog table.
/// </summary>
public uint TypeOID { get; internal set; }
/// <summary>
/// The OID of the PostgreSQL table of this column.
/// </summary>
public uint TableOID { get; internal set; }
/// <summary>
/// The column's position within its table. Note that this is different from <see cref="ColumnOrdinal" />,
/// which is the column's position within the resultset.
/// </summary>
public short? ColumnAttributeNumber { get; internal set; }
/// <summary>
/// The default SQL expression for this column.
/// </summary>
public string? DefaultValue { get; internal set; }
/// <summary>
/// The <see cref="NpgsqlDbType" /> value for this column's type.
/// </summary>
public NpgsqlDbType? NpgsqlDbType { get; internal set; }
/// <inheritdoc />
public override object? this[string propertyName]
=> propertyName switch
{
nameof(PostgresType) => PostgresType,
nameof(TypeOID) => TypeOID,
nameof(TableOID) => TableOID,
nameof(ColumnAttributeNumber) => ColumnAttributeNumber,
nameof(DefaultValue) => DefaultValue,
nameof(NpgsqlDbType) => NpgsqlDbType,
_ => base[propertyName]
};
#endregion Npgsql-specific fields
}