You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
@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?
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.
Reacted by Justin, Al, Andrew Stanton, PranavSah and David Faivre
@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.
@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.
@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.
@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.
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.
@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.
@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.
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.
This Microsoft article clearly demonstrates the advantages of using DataSets/DataTables to improve performance when connecting to an Azure SQL Database.
@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.
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.
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:
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.
@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?
@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).
Activity
saurabh500 commentedon May 17, 2016
cc @ajlam
roji commentedon May 29, 2016
@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?
nmunday commentedon Jun 1, 2016
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.
hejtmii commentedon Jun 3, 2016
@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.
sqmgh commentedon Jun 3, 2016
You can just use an
IEnumerable<SqlDataRecord>in place of a DataTablenmunday commentedon Jun 4, 2016
@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.
nmunday commentedon Jun 4, 2016
@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.
sqmgh commentedon Jun 6, 2016
@nmunday Add
System.Data.SqlClientto your dependencies, and it's inMicrosoft.SqlServer.Server. IntelliSense will recommend adding that using if you try and construct one. It's been in Core for quite a while.andrew-vdb commentedon Jun 9, 2016
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:
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.
nmunday commentedon Jun 13, 2016
@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.
sqmgh commentedon Jun 14, 2016
@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.
VitaliyMF commentedon Jul 5, 2016
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.
j055 commentedon Jul 18, 2016
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.
roji commentedon Jul 18, 2016
@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.
38 remaining items
ahhsoftware commentedon Oct 18, 2016
fair enough
On Tue, Oct 18, 2016 at 3:14 AM, Shay Rojansky [email protected]
wrote:
ahhsoftware commentedon Oct 18, 2016
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:
AdrienTorris commentedon Nov 6, 2016
@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
roji commentedon Nov 6, 2016
@AdrienTorris just scroll up this issue to see where it's closed: dotnet/corefx#12426
michal-ciechan commentedon Feb 26, 2017
What version of the s tandard is this included in?
svick commentedon Feb 27, 2017
@michal-ciechan According to apisof.net, it's .Net Standard 2.0.
ahhsoftware commentedon Feb 27, 2017
VitaliyMF commentedon Feb 28, 2017
@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.
ahhsoftware commentedon Feb 28, 2017
wendt88 commentedon Mar 2, 2017
@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?
VitaliyMF commentedon Mar 2, 2017
@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).
StingyJack commentedon Mar 8, 2017
So... rewrite and retest entire DAL or wait. Going to have to wait - far too much code.