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

Data.Common and SqlClient: considering adding an alternate version of GetFieldValueAsync<T>() that returns a ValueTask<T> #19858

Closed
divega opened this issue Jan 9, 2017 · 1 comment
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Data
Milestone

Comments

@divega
Copy link
Contributor

divega commented Jan 9, 2017

Based on the the description of ValueTask<TResult> and the discussion at https://github.com/dotnet/corefx/issues/4708 it seems that GetFieldValueAsync<T>() (on DbDataReader and derived types) could use it to enable more efficient fine-grained async code.

Note that we haven't performed any measurements to try to understand the impact of this change, and that the higher level components we work on such as EF6 and EF Core currently would not take advantage of it, but we are creating this issue to have a chance to evaluate this improvement for other code that uses this ADO.NET API directly.

Also note that fine-grained async APIs that return Task<bool> (such as ReadAsync() and IsDBNullAsync()) may return cached Task<bool> instances to gain efficiency instead of adopting ValueTask<TResult>.

From my perspective, there are a couple of open issues if we decided to do this:

  1. Naming of the new method: since there can't be yet another overload that only differs on the return type, and the "standard" name with just the Async suffix is taken.
  2. Compatibility for providers: It seems desirable to offer a default implementation of the Task-based method that calls AsTask() on the ValueTask<TResult> instance returned by the new API, so that new providers don't need to implement the old Task<TResult> version of the API but instead only implement the more efficient ValueTask<TResult> version. It also seems good not to force existing providers to switch.

I am currently thinking that adding an optional interface with the new API could be a solution, but there are other disadvantages in that approach.

cc @stephentoub @YoungGah @saurabh500

@divega divega changed the title Data.Common and SqlClient: considering adding an alternate version of GetFieldValueAsync<T>() that returns a ValueTask<TResult> Data.Common and SqlClient: considering adding an alternate version of GetFieldValueAsync<T>() that returns a ValueTask<T> Jan 10, 2017
@divega
Copy link
Contributor Author

divega commented Feb 1, 2019

Closing in favor of https://github.com/dotnet/corefx/issues/27682.

@divega divega closed this as completed Feb 1, 2019
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Data
Projects
None yet
Development

No branches or pull requests

2 participants