runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Consider adding FillAsync and async APIs on data adapters

Open spudcud opened this issue 9 years ago • 119 comments

Core 2.0 preview 1 now supports SqlDataAdapter and DataTable which is great and the best way to fill a DataSet from a stored procedure is by using SqlDataAdapter.Fill(DataSet). This works perfectly when not used in an async environment. There is currently no way in Core or full .NET to do a FillAsync. Without a FillAsync which would take a single line of code now requires 20 lines of much more complicated code including using SqlDataReader.GetSchemaTable() which is currently broken preview 1. Based on other posts I believe it will be working in Preview 2 but have not seen a definitive on that.

This is not something for 2.0 but is a clear deficiency in truly being able to support a fully async back-end and would be a much needed improvement moving forward.

spudcud avatar Jun 03 '17 01:06 spudcud

Moving to future because of lack of resources

saurabh500 avatar Jan 30 '18 18:01 saurabh500

Alternatively if someone from the community would like to drive this, the effort would be welcome.

saurabh500 avatar Jan 30 '18 18:01 saurabh500

This needs a formal API proposal written up. @spudcud do you want to do this - updating your top post is clearest? See https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md

danmoseley avatar Jan 30 '18 19:01 danmoseley

Not sure if this helps, but someone has implemented this.

https://github.com/voloda/AsyncDataAdapter/blob/master/AsyncDataAdapter/DataAdapter.cs

jonreis avatar Jan 31 '18 19:01 jonreis

@danmosemsft any chance this can be added to Core 3.0? I've added package suggested by @jonreis and it looks like it works fine 😄 Ideally this should be added into Core.

Misiu avatar Oct 16 '18 08:10 Misiu

+1 on this, Perhaps it about time to take care of it?

effyteva avatar Apr 11 '19 07:04 effyteva

@danmosemsft @saurabh500 any updates on this?

Misiu avatar Apr 11 '19 07:04 Misiu

+1

brendanalexdr avatar Apr 14 '19 17:04 brendanalexdr

@saurabh500?

danmoseley avatar Apr 14 '19 19:04 danmoseley

@divega

danmoseley avatar Apr 14 '19 19:04 danmoseley

Moving to out of System.Data.SqlClient and into System.Data because I believe the methods should be added to the base DbDataAdapter, before any provider implements it.

I am also keeping this issue in the Future milestone because we need a much better understanding of its impact before we decide to pick it up and implement it in a specific release. For example:

  1. How many modern applications that take advantage of async would start using async APIs on DataSet/DataAdapter if they were available? Why don't they use other more modern data access technologies that already support async? I appreciate that a few people have voted for this issue and have been asking for updates on it. This adds up to a bit of data, but we need more, especially given that there are many other things in the backlog that seem to have much more demand.

  2. Is the main goal of using async in this case mainly achieving better scalability on the server or more responsiveness on the client?

  3. What other API that perform I/O does Fill use, that would need to become async in order for FillAsync to avoid every blocking?

  4. What about the async Update story for DataSet/DataTable?

On the flip side, If someone from the community wanted to drive this, I believe the API design part, and possibly the implementation of FillAsync on SqlClient, would be relatively simple. The job is mostly to duplicate the code of the sync version into async methods, and also make sure that all potentially blocking calls in the implementation use async APIs as well.

For the SqlCient implementation of Update, currently batching is internal and synchronous. I suspect it would make sense to leverage the new public batching APIs from https://github.com/dotnet/corefx/issues/35135 once they are in place.

divega avatar Apr 14 '19 22:04 divega

cc @roji @ajcvickers

divega avatar Apr 14 '19 22:04 divega

Similar to dotnet/corefx#35012, which adds missing async APIs elsewhere in ADO.NET.

Adding these APIs in the System.Data base classes is probably easy enough (with them delegating by default to the sync APIs, as usual with ADO.NET), allowing providers to implement later.

roji avatar Apr 17 '19 11:04 roji

Similar to dotnet/corefx#35012, which adds missing async APIs elsewhere in ADO.NET.

Adding these APIs in the System.Data base classes is probably easy enough (with them delegating by default to the sync APIs, as usual with ADO.NET), allowing providers to implement later.

Would it help if I publish a PR for that? It seems pretty straightforward.

Effy

effyteva avatar May 13 '19 10:05 effyteva

Is this still under review?

uprightbass360 avatar May 19 '20 01:05 uprightbass360

@uprightbass360 this issue is currently in the backlog, which means we don't have immediate plans to implement it priority-wise. In general, investment in DbDataAdapter is mostly limited to maintenance at this point, but given enough user feedback we would definitely consider it. This could be a good issue for the community to look into.

roji avatar May 20 '20 06:05 roji

@maxle5 you added this feature to your fork. Any chance to create a PR?

Misiu avatar May 20 '20 07:05 Misiu

One small note - I haven't reviewed @maxle5's commit, but we'd want to add async across all operations performed by DbDataAdapter, and not just for some (FillAsync). We don't want to end up with a type that only partially supports async.

roji avatar May 20 '20 08:05 roji

@roji I think @maxle5's commit creates all the necessary methods: https://github.com/maxle5/runtime/commit/5d1f61d6c6322d351cbb02069b04eed0c04d208f#diff-fbc8b4fa5b891e40cb60fd8fd075cc81R1236-R1240 https://github.com/maxle5/runtime/commit/5d1f61d6c6322d351cbb02069b04eed0c04d208f#diff-fbc8b4fa5b891e40cb60fd8fd075cc81R1630-R1636 https://github.com/maxle5/runtime/commit/5d1f61d6c6322d351cbb02069b04eed0c04d208f#diff-fbc8b4fa5b891e40cb60fd8fd075cc81R2044-R2056 I haven't tried it, but it looks complete

Misiu avatar May 20 '20 08:05 Misiu

In that case a PR would be good to have!

roji avatar May 20 '20 09:05 roji