Skip to content

Commit ba8f12d

Browse files
committed
Implement new GetSchemaAsync API. Fixes #835
1 parent 2d03230 commit ba8f12d

File tree

4 files changed

+121
-13
lines changed

4 files changed

+121
-13
lines changed

docs/content/api/MySqlConnector/MySqlConnection/GetSchema.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ title: GetSchema
44

55
# MySqlConnection.GetSchema method (1 of 3)
66

7+
Returns schema information for the data source of this [`MySqlConnection`](../../MySqlConnectionType/).
8+
79
```csharp
810
public override DataTable GetSchema()
911
```
1012

13+
## Return Value
14+
15+
A DataTable containing schema information.
16+
1117
## See Also
1218

1319
* class [MySqlConnection](../../MySqlConnectionType/)
@@ -18,10 +24,20 @@ public override DataTable GetSchema()
1824

1925
# MySqlConnection.GetSchema method (2 of 3)
2026

27+
Returns schema information for the data source of this [`MySqlConnection`](../../MySqlConnectionType/).
28+
2129
```csharp
2230
public override DataTable GetSchema(string collectionName)
2331
```
2432

33+
| parameter | description |
34+
| --- | --- |
35+
| collectionName | The name of the schema to return. |
36+
37+
## Return Value
38+
39+
A DataTable containing schema information.
40+
2541
## See Also
2642

2743
* class [MySqlConnection](../../MySqlConnectionType/)
@@ -32,10 +48,21 @@ public override DataTable GetSchema(string collectionName)
3248

3349
# MySqlConnection.GetSchema method (3 of 3)
3450

51+
Returns schema information for the data source of this [`MySqlConnection`](../../MySqlConnectionType/).
52+
3553
```csharp
3654
public override DataTable GetSchema(string collectionName, string[] restrictions)
3755
```
3856

57+
| parameter | description |
58+
| --- | --- |
59+
| collectionName | The name of the schema to return. |
60+
| restrictions | The restrictions to apply to the schema; this parameter is currently ignored. |
61+
62+
## Return Value
63+
64+
A DataTable containing schema information.
65+
3966
## See Also
4067

4168
* class [MySqlConnection](../../MySqlConnectionType/)

docs/content/api/MySqlConnector/MySqlConnection/GetSchemaAsync.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,76 @@
22
title: GetSchemaAsync
33
---
44

5-
# MySqlConnection.GetSchemaAsync method
5+
# MySqlConnection.GetSchemaAsync method (1 of 3)
66

77
Asynchronously returns schema information for the data source of this [`MySqlConnection`](../../MySqlConnectionType/).
88

99
```csharp
10-
public Task<DataTable> GetSchemaAsync(string collectionName = null, string[] restrictions = null,
10+
public Task<DataTable> GetSchemaAsync(
1111
CancellationToken cancellationToken = default(CancellationToken))
1212
```
1313

1414
| parameter | description |
1515
| --- | --- |
16-
| collectionName | The schema name of data to be returned; if `null`, the `MetaDataCollections` schema is returned. |
16+
| cancellationToken | A token to cancel the asynchronous operation. |
17+
18+
## Return Value
19+
20+
A Task containing schema information.
21+
22+
## See Also
23+
24+
* class [MySqlConnection](../../MySqlConnectionType/)
25+
* namespace [MySqlConnector](../../MySqlConnectionType/)
26+
* assembly [MySqlConnector](../../../MySqlConnectorAssembly/)
27+
28+
---
29+
30+
# MySqlConnection.GetSchemaAsync method (2 of 3)
31+
32+
Asynchronously returns schema information for the data source of this [`MySqlConnection`](../../MySqlConnectionType/).
33+
34+
```csharp
35+
public Task<DataTable> GetSchemaAsync(string collectionName,
36+
CancellationToken cancellationToken = default(CancellationToken))
37+
```
38+
39+
| parameter | description |
40+
| --- | --- |
41+
| collectionName | The name of the schema to return. |
42+
| cancellationToken | A token to cancel the asynchronous operation. |
43+
44+
## Return Value
45+
46+
A Task containing schema information.
47+
48+
## See Also
49+
50+
* class [MySqlConnection](../../MySqlConnectionType/)
51+
* namespace [MySqlConnector](../../MySqlConnectionType/)
52+
* assembly [MySqlConnector](../../../MySqlConnectorAssembly/)
53+
54+
---
55+
56+
# MySqlConnection.GetSchemaAsync method (3 of 3)
57+
58+
Asynchronously returns schema information for the data source of this [`MySqlConnection`](../../MySqlConnectionType/).
59+
60+
```csharp
61+
public Task<DataTable> GetSchemaAsync(string collectionName, string[] restrictions,
62+
CancellationToken cancellationToken = default(CancellationToken))
63+
```
64+
65+
| parameter | description |
66+
| --- | --- |
67+
| collectionName | The name of the schema to return. |
1768
| restrictions | The restrictions to apply to the schema; this parameter is currently ignored. |
1869
| cancellationToken | A token to cancel the asynchronous operation. |
1970

71+
## Return Value
72+
73+
A Task containing schema information.
74+
2075
## See Also
2176

2277
* class [MySqlConnection](../../MySqlConnectionType/)

docs/content/api/MySqlConnector/MySqlConnectionType.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public sealed class MySqlConnection : DbConnection, ICloneable
3939
| [CreateCommand](../MySqlConnection/CreateCommand/)() | |
4040
| override [DisposeAsync](../MySqlConnection/DisposeAsync/)() | |
4141
| override [EnlistTransaction](../MySqlConnection/EnlistTransaction/)(…) | |
42-
| override [GetSchema](../MySqlConnection/GetSchema/)() | |
43-
| override [GetSchema](../MySqlConnection/GetSchema/)(…) | (2 methods) |
44-
| [GetSchemaAsync](../MySqlConnection/GetSchemaAsync/)(…) | Asynchronously returns schema information for the data source of this [`MySqlConnection`](../MySqlConnectionType/). |
42+
| override [GetSchema](../MySqlConnection/GetSchema/)() | Returns schema information for the data source of this [`MySqlConnection`](../MySqlConnectionType/). |
43+
| override [GetSchema](../MySqlConnection/GetSchema/)(…) | Returns schema information for the data source of this [`MySqlConnection`](../MySqlConnectionType/). (2 methods) |
44+
| [GetSchemaAsync](../MySqlConnection/GetSchemaAsync/)(…) | Asynchronously returns schema information for the data source of this [`MySqlConnection`](../MySqlConnectionType/). (3 methods) |
4545
| override [Open](../MySqlConnection/Open/)() | |
4646
| override [OpenAsync](../MySqlConnection/OpenAsync/)(…) | |
4747
| [Ping](../MySqlConnection/Ping/)() | |

src/MySqlConnector/MySqlConnection.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,24 +513,50 @@ private static async Task ClearPoolAsync(MySqlConnection connection, IOBehavior
513513
#if !NETSTANDARD1_3
514514
protected override DbProviderFactory DbProviderFactory => MySqlConnectorFactory.Instance;
515515

516-
/// <inheritdoc cref="DbConnection.GetSchema()"/>
516+
/// <summary>
517+
/// Returns schema information for the data source of this <see cref="MySqlConnection"/>.
518+
/// </summary>
519+
/// <returns>A <see cref="DataTable"/> containing schema information.</returns>
517520
public override DataTable GetSchema() => GetSchemaProvider().GetSchemaAsync(IOBehavior.Synchronous, default).GetAwaiter().GetResult();
518521

519-
/// <inheritdoc cref="DbConnection.GetSchema(string)"/>
522+
/// <summary>
523+
/// Returns schema information for the data source of this <see cref="MySqlConnection"/>.
524+
/// </summary>
525+
/// <param name="collectionName">The name of the schema to return.</param>
526+
/// <returns>A <see cref="DataTable"/> containing schema information.</returns>
520527
public override DataTable GetSchema(string collectionName) => GetSchemaProvider().GetSchemaAsync(IOBehavior.Synchronous, collectionName, default).GetAwaiter().GetResult();
521528

522-
/// <inheritdoc cref="DbConnection.GetSchema(string)"/>
529+
/// <summary>
530+
/// Returns schema information for the data source of this <see cref="MySqlConnection"/>.
531+
/// </summary>
532+
/// <param name="collectionName">The name of the schema to return.</param>
533+
/// <param name="restrictions">The restrictions to apply to the schema; this parameter is currently ignored.</param>
534+
/// <returns>A <see cref="DataTable"/> containing schema information.</returns>
523535
public override DataTable GetSchema(string collectionName, string?[] restrictions) => GetSchemaProvider().GetSchemaAsync(IOBehavior.Synchronous, collectionName, default).GetAwaiter().GetResult();
524536

525537
/// <summary>
526538
/// Asynchronously returns schema information for the data source of this <see cref="MySqlConnection"/>.
527539
/// </summary>
528-
/// <param name="collectionName">The schema name of data to be returned; if <c>null</c>, the <c>MetaDataCollections</c> schema is returned.</param>
540+
/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
541+
/// <returns>A <see cref="Task{DataTable}"/> containing schema information.</returns>
542+
public Task<DataTable> GetSchemaAsync(CancellationToken cancellationToken = default) => GetSchemaProvider().GetSchemaAsync(AsyncIOBehavior, cancellationToken).AsTask();
543+
544+
/// <summary>
545+
/// Asynchronously returns schema information for the data source of this <see cref="MySqlConnection"/>.
546+
/// </summary>
547+
/// <param name="collectionName">The name of the schema to return.</param>
548+
/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
549+
/// <returns>A <see cref="Task{DataTable}"/> containing schema information.</returns>
550+
public Task<DataTable> GetSchemaAsync(string collectionName, CancellationToken cancellationToken = default) => GetSchemaProvider().GetSchemaAsync(AsyncIOBehavior, collectionName, cancellationToken).AsTask();
551+
552+
/// <summary>
553+
/// Asynchronously returns schema information for the data source of this <see cref="MySqlConnection"/>.
554+
/// </summary>
555+
/// <param name="collectionName">The name of the schema to return.</param>
529556
/// <param name="restrictions">The restrictions to apply to the schema; this parameter is currently ignored.</param>
530557
/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
531-
/// <returns></returns>
532-
public Task<DataTable> GetSchemaAsync(string? collectionName = null, string?[]? restrictions = null, CancellationToken cancellationToken = default) =>
533-
GetSchemaProvider().GetSchemaAsync(IOBehavior.Asynchronous, collectionName ?? "MetaDataCollections", cancellationToken).AsTask();
558+
/// <returns>A <see cref="Task{DataTable}"/> containing schema information.</returns>
559+
public Task<DataTable> GetSchemaAsync(string collectionName, string?[] restrictions, CancellationToken cancellationToken = default) => GetSchemaProvider().GetSchemaAsync(AsyncIOBehavior, collectionName, cancellationToken).AsTask();
534560

535561
private SchemaProvider GetSchemaProvider() => m_schemaProvider ??= new(this);
536562

0 commit comments

Comments
 (0)