Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API Proposal]: Add FillAsync and FillSchemaAsync to DataAdapter #101704

Closed
gumbarros opened this issue Apr 30, 2024 · 5 comments
Closed

[API Proposal]: Add FillAsync and FillSchemaAsync to DataAdapter #101704

gumbarros opened this issue Apr 30, 2024 · 5 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Data

Comments

@gumbarros
Copy link

gumbarros commented Apr 30, 2024

Background and motivation

Background:
DataAdapter is a essential component for data access and manipulation in .NET applications without reeling on third party packages. The derived classes provide methods for retrieving and updating data from databases. However, with the increasing demand for asynchronous programming patterns and the advent of async/await in C#, developers often face challenges when working with synchronous data adapters in asynchronous workflows.
There is lots of discussions at #22109 and a entire PR without feedback at #36746 (credits for @maxle5 and thank you for the design at the PR).

Motivation:
The motivation behind adding FillAsync and FillSchemaAsync, stems from the need to improve performance and responsiveness in modern .NET applications. Asynchronous programming allows developers to write non-blocking code, which can significantly enhance the scalability and efficiency of applications, especially when dealing with I/O-bound operations like database queries.

By introducing FillAsync and FillSchemaAsyncto ADO.NET data adapters, developers can leverage asynchronous programming techniques more seamlessly without the need to rely to custom solutions or 3rd party packages.

API Proposal

namespace System.Data.Common;

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public class DataAdapter : Component, IDataAdapter
{
    public virtual Task<int> FillAsync(DataSet dataSet);
    protected virtual Task<int> FillAsync(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords);
    protected virtual Task<int> FillAsync(DataTable dataTable, IDataReader dataReader);
    protected virtual Task<int> FillAsync(DataTable[] dataTables, IDataReader dataReader, int startRecord, int maxRecords);
    public virtual Task<DataTable[]> FillSchemaAsync(DataSet dataSet, SchemaType schemaType);
    protected virtual Task<DataTable[]> FillSchemaAsync(DataSet dataSet, SchemaType schemaType, string srcTable, IDataReader dataReader);
    protected virtual Task<DataTable> FillSchemaAsync(DataTable dataTable, SchemaType schemaType, IDataReader dataReader);
}

API Usage

using var dbCommand = CreateDbCommand("SELECT * FROM FOO");
dbCommand.Connection =CreateConnection();
using var dataSet = new DataSet();
using (dbCommand.Connection)
{
    using var dataAdapter = new SqlDataAdapter();
    dataAdapter!.SelectCommand = dbCommand;
    await dataAdapter.FillAsync(dataSet);
}

Alternative Designs

No response

Risks

No response

@gumbarros gumbarros added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Apr 30, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 30, 2024
Copy link
Contributor

Tagging subscribers to this area: @roji, @ajcvickers
See info in area-owners.md if you want to be subscribed.

@roji
Copy link
Member

roji commented Apr 30, 2024

@gumbarros is this a duplicate of #22109?

@gumbarros
Copy link
Author

A formal API proposal, the PR said there is no design and was recused because of this

@roji
Copy link
Member

roji commented May 2, 2024

@gumbarros a semi-formal API proposal was already done in #22109 (comment). In any case, an API proposal isn't blocking the progress of this issue - API-wise this is just about adding async counterparts to existing sync APIs.

The issues here are more around implementation - both the necessary usage of default interface implementations (DIMs) and in general, plumbing the entire async support through DbDataAdapter. Importantly, DbDataAdapter is also generally considered legacy, and as a result we're generally not investing much effort in features in that area; stability and not breaking the existing code is the priority. This isn't to say that async support won't happen, but so far it hasn't bubbled up to the top of the priority list.

In any case, am closing this in favor of #22109.

@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
@roji
Copy link
Member

roji commented May 2, 2024

Duplicate of #22109

@roji roji marked this as a duplicate of #22109 May 2, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label May 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Data
Projects
None yet
Development

No branches or pull requests

2 participants