Skip to content

Add PrepareAsync() to DbCommand #24244

Closed
Closed

Description

@roji

ADO.NET includes DbCommand.Prepare() for command preparation, to speed up subsequent repeated executions of the command. As this method may perform I/O to create a server-side statement, it should have a DbCommand.PrepareAsync() counterpart. As with other ADO.NET async overloads, DbCommand should provide a default implementation which delegates to the sync version.

Activity

  1. JonHanna commented on Nov 26, 2017

    @JonHanna
    Contributor

    Agreed. I remember working on that NpgsqlCommand.Prepare() override some time ago, and it is a very natural method for an async version. I would assume the same would be true of other providers.

    The API could be:

    public abstract class DbCommand
    {
        public virtual Task PrepareAsync(CancellationToken cancellationToken = default);
    }

    (The implementation need only be {Prepare(); return Task.CompletedTask();}).

  2. divega commented on Feb 8, 2018

    @divega
    Contributor

    System.Data Triage: This looks like a good idea, although we are not going to implement it right away.
    This related to another issue that calls for implementing async versions of other APIs that can block now.
    Moving to Future.

  3. roji commented on Feb 1, 2019

    @roji
    MemberAuthor

    Closing in favor of dotnet/corefx#35012

  4. transferred this issue fromdotnet/corefxon Jan 31, 2020
  5. added this to the 3.0 milestone on Jan 31, 2020
  6. ghost locked as resolved and limited conversation to collaborators on Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Data

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions