Skip to content

DataTable like API in .Net Core #17314

Closed
dotnet/corefx
#12426

Description

@saurabh500

System.Data.DataTable is present in .Net core as an empty class to complete the interfaces implementation.
This issue is to track the work needed to bring in an API to provide DataTable like API in .Net Core.

Activity

  1. self-assigned this
    on May 17, 2016
  2. saurabh500 commented on May 17, 2016

    @saurabh500
    ContributorAuthor
  3. roji commented on May 29, 2016

    @roji
    Member

    @saurabh500 does this mean you guys are bringing back DataTable to .NET Core? Or are you planning to introduce a new API the performs some (or all) of DataTable's tasks?

    FWIW I do think that dropping DataTable/DataSet is a good idea. I'm wondering if you guys are considering bringing it back purely for backwards-compatibility reasons or is there something else?

  4. nmunday commented on Jun 1, 2016

    @nmunday

    Hopefully the right place to post this. Will this include the ability to use a DataTable as a parameter in a stored procedure call? I have lots of SP's that take a TableValue parameter. In ADO.NET I fill a DataTable with data and pass it using SqlDbType.Structured as the parameter type. Unless there is currently another way to do this?

    I do not think that sending a whole bunch of insert/update/delete statements is a viable alternative.

  5. hejtmii commented on Jun 3, 2016

    @hejtmii

    @nmunday maybe there already is an option to do that. SqlBulkCopy now accepts DbDataReader as an input instead of DataTable so I expect that this could work similar way, try pass DbDataReader instead of DataTable as the parameter. If not, I second that it should be possible somehow.

  6. sqmgh commented on Jun 3, 2016

    @sqmgh

    You can just use an IEnumerable<SqlDataRecord> in place of a DataTable

  7. nmunday commented on Jun 4, 2016

    @nmunday

    @sqmgh where would I find such a class (SqlDataRecord) in .NET Core? I tried the docs and intelisense in VS and it does not seem to be there. In the full framework SqlDataReader implements IDataRecord but not so in .NET Core.

  8. nmunday commented on Jun 4, 2016

    @nmunday

    @kenticomartinh that may work for some of the SP's that do straight inserts. Many SP's contain other logic that is executed at the same time, some SP's do not even end up inserting data at all. I will look into SqlBulkCopy for sure and use it when it does the job. Thanks.

  9. sqmgh commented on Jun 6, 2016

    @sqmgh

    @nmunday Add System.Data.SqlClient to your dependencies, and it's in Microsoft.SqlServer.Server. IntelliSense will recommend adding that using if you try and construct one. It's been in Core for quite a while.

  10. andrew-vdb commented on Jun 9, 2016

    @andrew-vdb

    DataTable/DataSet is rich in features, bit bloated but it do the job well.
    Not sure the real reason why this object should be dropped.

    Some notable features are:

    • Deserialize/Serialize schema and data from/to xml
    • Column expression
    • Change tracking via DataRowState
    • Copyable and cloneable object
    • Column's default value
    • DataView
    • etc

    If there is something bad is that its store the data with object array which promote boxing and unboxing, this hopefully solved by tuple in c# 7 maybe
    Accept/Reject Change bit tricky to use but it works

    Not everyone use ORM, not everyone use EF. Those who stay with ADO.NET should be punished like this. Those who battle with database query optimizer understand the pain losing control over your query because your query is automatically generated.

    You use Stored Procedure, you change your select statement, you don't want to change the application just because your schema is changing.

    With DataSet and DataTable I feel like having in memory database.

    Optimize the object, make it lighter, faster but dropping its features.

  11. nmunday commented on Jun 13, 2016

    @nmunday

    @sqmgh thanks for the pointers. I did indeed find the class once I added the SqlClient reference. Not sure how I missed it. The code is now working. I was always unsatisfied with loading a DataTable just to then send it to a stored procedure. Seemed like a waste of memory and resources. Now by streaming with SQLDataRecord I can avoid the load altogether. Thanks again.

  12. sqmgh commented on Jun 14, 2016

    @sqmgh

    @nmunday No problem, and glad I could help. I was doing the exact same thing in the past, and I felt the exact same way before I discovered that I could just yield SqlDataRecords.

    After that point I basically never used DataTable again. Now they just seem like a janky and overly complex for what you get ORM.

    I suppose could potentially see some use for them in a very quick application where you have to load tabular data without knowing what columns will exist. However, that doesn't ever apply to me personally. I only ever deal in situations where I at least know which columns might be there. In that case I think it's more than worth the effort to just generate a record class. Dealing with hard typed columns tend to make the codes way easier to read or write, and that's without even looking at things on the performance and reliability side.

  13. VitaliyMF commented on Jul 5, 2016

    @VitaliyMF

    It seems many people are asking for something lightweight between EF Core and low-level System.Data.Common interfaces. I'm the author of the NI.Data library (.NET 4.x) that offers abstract (db-independent) queries and simple db-independent interface for CRUD-operations. I can port most demanded parts to a new corefx-oriented library (queries, dataview-abstractions, SQL-generation components) with a simple interface for high-performance operations with POCO and/or IDictionary instead of DataTable/DataRow. If someone is interested in this library don't hesitate to contact me.

    UPD: just finished first version of data access library (supports both .NET Core and .NET 4.x) that implements SQL command builder and data adapter for CRUD operations: NReco.Data library. I hope it will be helpful for everyone who looking for DataRow/DataTable/SqlCommandBuilder/DbDataAdapter alternative in .NET Core.

  14. j055 commented on Jul 18, 2016

    @j055

    This Microsoft article clearly demonstrates the advantages of using DataSets/DataTables to improve performance when connecting to an Azure SQL Database.

    https://azure.microsoft.com/en-gb/documentation/articles/sql-database-use-batching-to-improve-performance/

    corefx needs this to work nicely with Microsoft's own SQL Database service.

  15. roji commented on Jul 18, 2016

    @roji
    Member

    @j055 I don't think there's any performance optimization provided by DataSets/DataTables that isn't possible with regular commands. You can batch multiple inserts into a single DbCommand just as easily.

  16. 38 remaining items

  17. ahhsoftware commented on Oct 18, 2016

    @ahhsoftware

    fair enough

    On Tue, Oct 18, 2016 at 3:14 AM, Shay Rojansky [email protected]
    wrote:

    @ahhsoftware https://github.com/ahhsoftware, you seem to be
    misunderstanding the conversation.

    The current version of .NET Core does not have DataSet/DataTable, this
    will not change. The next version of .NET Core will have
    DataSet/DataTable - this has already been confirmed here. There's no need
    to say how important these components are for you.

    However, it's important to understand that what you're accomplishing with
    DataSet/DataTable can be accomplished with other means. In other words,
    if you need to port to .NET Core today than you have options for
    dropping DataSet/DataTable. Otherwise you can wait for netstandard20 which
    will have DataSet/DataTable, and your current code should work without
    changes then.

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub
    https://github.com/dotnet/corefx/issues/8622#issuecomment-254425783, or mute
    the thread
    https://github.com/notifications/unsubscribe-auth/ARDmFJZC0d6dv5p3DSFK5rN-QVmuzn5Yks5q1HHTgaJpZM4IgwIS
    .

  18. ahhsoftware commented on Oct 18, 2016

    @ahhsoftware

    Hey, while you're in there you might want to discover a better approach to
    processing JSON results. As it stands there is a character limit on
    execute scalar, so we typically have to loop through the reader with a
    string builder at index 0. It would nice to have a method
    cmd.ExecuteJson() or something along those lines that would do the same
    thing under the covers.

    Maybe not make things sealed either, if I could derive from a parameter I
    could build out a more customized tier.

    Just thoughts

    On Tue, Oct 18, 2016 at 10:23 AM, alan hyneman [email protected]
    wrote:

    fair enough

    On Tue, Oct 18, 2016 at 3:14 AM, Shay Rojansky [email protected]
    wrote:

    @ahhsoftware https://github.com/ahhsoftware, you seem to be
    misunderstanding the conversation.

    The current version of .NET Core does not have DataSet/DataTable, this
    will not change. The next version of .NET Core will have
    DataSet/DataTable - this has already been confirmed here. There's no need
    to say how important these components are for you.

    However, it's important to understand that what you're accomplishing with
    DataSet/DataTable can be accomplished with other means. In other
    words, if you need to port to .NET Core today than you have options
    for dropping DataSet/DataTable. Otherwise you can wait for netstandard20
    which will have DataSet/DataTable, and your current code should work
    without changes then.

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub
    https://github.com/dotnet/corefx/issues/8622#issuecomment-254425783,
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/ARDmFJZC0d6dv5p3DSFK5rN-QVmuzn5Yks5q1HHTgaJpZM4IgwIS
    .

  19. AdrienTorris commented on Nov 6, 2016

    @AdrienTorris

    @roji You said DataSet and DataTable will be in the next version of .NET Core, where did you see that ? I didn't see this feature in the roadmap

  20. roji commented on Nov 6, 2016

    @roji
    Member

    @AdrienTorris just scroll up this issue to see where it's closed: dotnet/corefx#12426

  21. michal-ciechan commented on Feb 26, 2017

    @michal-ciechan

    What version of the s tandard is this included in?

  22. svick commented on Feb 27, 2017

    @svick
    Member

    @michal-ciechan According to apisof.net, it's .Net Standard 2.0.

  23. ahhsoftware commented on Feb 27, 2017

    @ahhsoftware
  24. VitaliyMF commented on Feb 28, 2017

    @VitaliyMF

    @ahhsoftware I already mentioned previously that you can pass table-valued parameters with netstandard1.6, you don't need to wait for netstandard2.0 and DataSet/DataTable; netcore implementation of SqlClient support this type of parameters, and you can pass TVP with custom implementation of DbDataReader. As alternative, you can use NReco.Data library that implements RecordSet structure and RecordSetReader that could be used for specifying TVP in similar way to DataTable.

  25. ahhsoftware commented on Feb 28, 2017

    @ahhsoftware
  26. wendt88 commented on Mar 2, 2017

    @wendt88

    @VitaliyMF i tried the NReco.Data library and it is a nice library, BUT can you tell me how to make queries on a table with custom schema name, or how to make joins?

  27. VitaliyMF commented on Mar 2, 2017

    @VitaliyMF

    @wendt88 could you add an issue with your questions to nreco/data, I think it is offtopic providing an answers here (it is possible to specify custom schema name; complex selects with joins should be declared as "virtual" dataviews processed by the library on .net side).

  28. StingyJack commented on Mar 8, 2017

    @StingyJack

    So... rewrite and retest entire DAL or wait. Going to have to wait - far too much code.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions