Skip to content

Commit 0fd1ee4

Browse files
committed
Standardise API on all platforms.
1 parent 518513b commit 0fd1ee4

File tree

2 files changed

+36
-40
lines changed

2 files changed

+36
-40
lines changed

src/MySqlConnector/MySqlClient/MySqlDataReader.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,11 @@ public override void Close()
238238
}
239239
#endif
240240

241-
#if NETSTANDARD1_3 || NETSTANDARD2_0
242241
public ReadOnlyCollection<DbColumn> GetColumnSchema()
243-
#else
244-
public ReadOnlyCollection<MySqlDbColumn> GetColumnSchema()
245-
#endif
246242
{
247243
return GetResultSet().ColumnDefinitions
248-
.Select((c, n) => new MySqlDbColumn(n, c, GetFieldType(n), GetDataTypeName(n)))
249-
#if NETSTANDARD1_3 || NETSTANDARD2_0
250-
.Cast<DbColumn>()
251-
#endif
252-
.ToList()
253-
.AsReadOnly();
244+
.Select((c, n) => (DbColumn) new MySqlDbColumn(n, c, GetFieldType(n), GetDataTypeName(n)))
245+
.ToList().AsReadOnly();
254246
}
255247

256248
public override T GetFieldValue<T>(int ordinal)

src/MySqlConnector/MySqlClient/MySqlDbColumn.cs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,42 @@
11
using System;
2-
using System.Data.Common;
32
using MySql.Data.Serialization;
43

5-
namespace MySql.Data.MySqlClient
4+
#if !NETSTANDARD1_3 && !NETSTANDARD2_0
5+
namespace System.Data.Common
66
{
7-
public sealed class MySqlDbColumn
8-
#if NETSTANDARD1_3 || NETSTANDARD2_0
9-
: DbColumn
7+
public abstract class DbColumn
8+
{
9+
public bool? AllowDBNull { get; protected set; }
10+
public string BaseCatalogName { get; protected set; }
11+
public string BaseColumnName { get; protected set; }
12+
public string BaseSchemaName { get; protected set; }
13+
public string BaseServerName { get; protected set; }
14+
public string BaseTableName { get; protected set; }
15+
public string ColumnName { get; protected set; }
16+
public int? ColumnOrdinal { get; protected set; }
17+
public int? ColumnSize { get; protected set; }
18+
public bool? IsAliased { get; protected set; }
19+
public bool? IsAutoIncrement { get; protected set; }
20+
public bool? IsExpression { get; protected set; }
21+
public bool? IsHidden { get; protected set; }
22+
public bool? IsIdentity { get; protected set; }
23+
public bool? IsKey { get; protected set; }
24+
public bool? IsLong { get; protected set; }
25+
public bool? IsReadOnly { get; protected set; }
26+
public bool? IsUnique { get; protected set; }
27+
public int? NumericPrecision { get; protected set; }
28+
public int? NumericScale { get; protected set; }
29+
public string UdtAssemblyQualifiedName { get; protected set; }
30+
public Type DataType { get; protected set; }
31+
public string DataTypeName { get; protected set; }
32+
public virtual object this[string property] => null;
33+
}
34+
}
1035
#endif
36+
37+
namespace MySql.Data.MySqlClient
38+
{
39+
public sealed class MySqlDbColumn : System.Data.Common.DbColumn
1140
{
1241
internal MySqlDbColumn(int ordinal, ColumnDefinitionPayload column, Type type, string dataTypeName)
1342
{
@@ -47,30 +76,5 @@ internal MySqlDbColumn(int ordinal, ColumnDefinitionPayload column, Type type, s
4776
}
4877

4978
public int ProviderType { get; }
50-
51-
#if !NETSTANDARD1_3 && !NETSTANDARD2_0
52-
public bool? AllowDBNull { get; }
53-
public string BaseCatalogName { get; }
54-
public string BaseColumnName { get; }
55-
public string BaseSchemaName { get; }
56-
public string BaseTableName { get; }
57-
public string ColumnName { get; }
58-
public int? ColumnOrdinal { get; }
59-
public int? ColumnSize { get; }
60-
public Type DataType { get; }
61-
public string DataTypeName { get; }
62-
public bool? IsAliased { get; }
63-
public bool? IsAutoIncrement { get; }
64-
public bool? IsExpression { get; }
65-
public bool? IsHidden { get; }
66-
public bool? IsIdentity { get; }
67-
public bool? IsKey { get; }
68-
public bool? IsLong { get; }
69-
public bool? IsReadOnly { get; }
70-
public bool? IsUnique { get; }
71-
public int? NumericPrecision { get; }
72-
public int? NumericScale { get; }
73-
public string UdtAssemblyQualifiedName { get; }
74-
#endif
7579
}
7680
}

0 commit comments

Comments
 (0)