Skip to content

Async System.Data resultset and database schema APIs #38028

@roji

Description

@roji

Provider tracking issues

This new API has been merged, following are tracking issues for implementation in the different providers:

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions