-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Data
Milestone
Description
Provider tracking issues
This new API has been merged, following are tracking issues for implementation in the different providers:
- SqlClient: .NET 5.0 | Add async System.Data resultset and database schema APIs SqlClient#646
- Npgsql: Introduce async schema APIs on connection and reader npgsql/npgsql#2976
MySqlConnector: Async resultset and database schema APIs mysql-net/MySqlConnector#835
Background and Motivation
This proposal introduces async counterparts to existing sync APIs for fetching schema information for resultset and database schema. The original proposal was developed by @manandre and @bgrainger in npgsql/npgsql#2976.
Proposed API
public class DbConnection
{
public virtual Task<DataTable> GetSchemaAsync(string collectionName = null, string[] restrictions = null, CancellationToken cancellationToken = default);
}
public class DbDataReader
{
public virtual Task<DataTable> GetSchemaTableAsync(CancellationToken cancellationToken = default);
}
public interface IDbColumnSchemaGenerator
{
Task<ReadOnlyCollection<DbColumn>> GetColumnSchemaAsync(CancellationToken cancellationToken = default);
}
public static class DbDataReaderExtensions
{
public static Task<ReadOnlyCollection<DbColumn>> GetColumnSchemaAsync(this DbDataReader reader, CancellationToken cancellationToken = default);
}
Notes
- The default implementations of the above will call the appropriate sync counterpart, as is standard in ADO.NET.
- As these APIs aren't perf-sensitive, they return Task instead of ValueTask. Since they typically return a considerable amount of data, the extra allocation is unlikely to matter in any case. They also mostly return asynchronously.
/cc @David-Engel @cheenamalhotra @bgrainger @manandre @bricelam @ajcvickers @stephentoub @terrajobst @mgravell @FransBouma
bgrainger, cheenamalhotra, manandre, bilalchraibi and Greeng0
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Data