runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Why is DataTable/View/Set absent?

Open FransBouma opened this issue 11 years ago • 155 comments

I looked here: https://github.com/dotnet/corefx-progress and saw DataTable/View/Set isn't ported to .NET Core. IMHO this is a mistake, as DataTable and friends are a convenient way to handle untyped data at runtime, and is e.g. often used when fetching data through stored procedures as it's easy to e.g. fetch a dataset with the result of a proc which returns 3 cursors on e.g. Oracle.

I fail to see why this cornerstone of many people's data-access code is absent in a framework that targets servers.

FransBouma avatar Feb 27 '15 08:02 FransBouma

@terrajobst When you have some free time perhaps you could give an overview about how we came up with what we think the surface area for .NET Core v1.0 is?

ellismg avatar Feb 27 '15 21:02 ellismg

Whatever may be the reason, having no real story for how to fetch tabular data using stored procs, which is today mostly done using DbDataAdapters storing data in DataSet/Tables, is likely going to stop a lot of people migrating their code to .NET Core for the simple reason that a lot of people have to work with stored procs and the tabular data they return every day. While it might be that a datareader opened on a proc call's resultset and materializing the rows into objects is 'easy', fact is that on databases which return cursors, this isn't that easy, while DbDataAdapters solve that problem today with a few lines of code.

I do understand DataTable/View/Set and DbDataAdapter come with a fair set of interfaces you likely don't want to port now (not sure if they are, haven't checked), e.g. IBindingList, IListSource and the like, but IMHO it's a cornerstone for Data access on .NET, despite what some hip people think.

FransBouma avatar Feb 27 '15 22:02 FransBouma

I want to extend the question: I understand that .Net Core is not the full .Net Framework and some features are cut out. Nevertheless, many of us rely on some features and want to migrate to .Net Core. But there are two groups: The impossible ones (e.g. WebForms / WPF) and the possible and even reasonable packages like e.g. DataTable/View, XmlSchema, SerialPort, System.Activities, etc. Some may have technical constraints, not be hip, or legally restrained but to know the status and strategy of them would be a great help for understanding this new .Net.

For these cut-out features will there be

  • separate NuGet packages outside (or in a later version) of the .Net Core?
  • and if yes, will the be created/maintained by Microsoft or should we expect that we need to go to the reference source and do it on our own? (not that this is wrong ... it is just something many employers will not pay for).
  • is there an overview of these gaps? I was surprised by XmlSchema (imagine the thousands of existing services), SerialPort (imagine all the inexpensive USB chips which create a virtual COM port) and now by DataTable. The analyzer only helps me with existing code but does not help me in first place when I have to decide on paper which framework to use.

I have not heard of a general strategy for these gaps, maybe I lost it somewhere.

tthiery avatar Mar 02 '15 11:03 tthiery

I ran into a use case today where I needed DataTable in order to return dynamic data to a service client. JSON.NET can easily serialize data tables for example. There are no easy solutions for materializing DYNAMIC data in .NET and DataTables make it easy when you don't know what the heck you're going to get back and you need to iterate over it. It's very useful for a number of things...

I can see why DataSet/DataTable is falling out of favor. Personally I rarely use them, but for dynamic data scenarios they are often the best choice available in .NET. So I hope we get this at some point or else an alternative that makes it easier to get dynamic data that can actually be serialized.

RickStrahl avatar Mar 03 '15 10:03 RickStrahl

There's another problem: DbConnection.GetSchema(). It's a way to obtain meta-data from the connected database and all ADO.NET providers have support for it, often with detailed schemas about metadata which can be used by data-access code to e.g. generate code on the fly for types or parameters. A lot of work has been put into this method by ADO.NET providers to make this method work on the database the provider is for: often they use detailed metadata queries so the user of the method doesn't have to.

GetSchema() returns a DataTable, as it's unknown what the types are of the rows returned as that depends on the schema requested and the ado.net provider used.

This method can't be used in .NET core if DataTable isn't there.

FransBouma avatar Mar 05 '15 08:03 FransBouma

Why is DataTable/View/Set absent?

We generally consider DataSet and friends (DataTable, DataView, TableAdapter) legacy. However, that doesn't necessarily mean that those APIs will never be available on .NET Core as we generally do support legacy APIs if they important for porting scenarios (for example, non-generic collections are also available for .NET Core).

So why are these types missing then? Simply because we're focusing on non-legacy components first and so far DataTable hasn't popped up yet.

terrajobst avatar Mar 05 '15 23:03 terrajobst

@terrajobst Answered also my question. A list of "legacy" .Net Framework technologies would be awesome (maybe including a state like "never", "maybe", "later"). I need to understand, in which technologies I can trust.

tthiery avatar Mar 06 '15 06:03 tthiery

@terrajobst and what about the scenarios I brought up? You can state something is 'legacy' in your eyes but that doesn't necessarily mean use cases a lot of devs are faced with every day are simply 'gone' or have valuable alternatives (as there are no alternatives at this point).

Sure, someone can port the code from referencesource and that might look OK, but it's not, as those types aren't the same types exposed and used in the ADO.NET providers.

I don't have the feeling Microsoft really understands the seriousness of this problem.

FransBouma avatar Mar 06 '15 07:03 FransBouma

I wish an alternative to SqlDbReader GetScema before makes DataTable and DataSet etc to be legacy and discontinued

My point DataTable is needed for metadata access and some of development work in now can not be obsolete and needs maintain works fine

kazuk avatar Mar 06 '15 13:03 kazuk

@FransBouma It is a serious problem for you, because you maintain database products that depend on DataTable functionality. I bet the number of people like you vs the rest of .NET developers is like a fraction of 1%. And a small one, at that.

When rewriting a framework, some stuff gets left behind, especially anything in the edge cases. All of the cases you made are edge cases. You may spend most of your life in them, and many others might because they use your products. But they are not Microsoft's focus moving forward. DataTables are a 15 year old technology, and there has to be a better way to do some of the things you described.

There are reasons EF7 is only usable for simple next-gen ASP.NET apps, and some of the scenarios you mentioned are among those reasons.

For anyone building things that are beyond simple apps, ASP.NET v6 on .NET 4.6 is going to be the way to go. DotNet Core will not be usable for many people in v1, and that is OK. Not every single feature can come along for the ride, otherwise if everything is legacy than nothing is.

Frans, You can't tell me you couldn't come up with a better way to write DbConnection.GetSchema() that could work in your own apps for .NET Core if you really thought about it. Write it as an extension method on DbConnection and make it work with older versions of the framework by using your own objects. Can't be that hard.

robertmclaws avatar Mar 06 '15 22:03 robertmclaws

@advancedrei

It is a serious problem for you, because you maintain database products that depend on DataTable functionality.

My tools don't depend on datatable in their core, they use datatables for meta-data retrieval in some situations (as metadata is only exposed through datatables in these situations)

I bet the number of people like you vs the rest of .NET developers is like a fraction of 1%. And a small one, at that.

Please don't make up numbers and pass them on as real. Almost every application calling stored procedures uses them, and of those applications there are many.

DataTables are a 15 year old technology, and there has to be a better way to do some of the things you described.

There's always a better way, sadly there's not one available at the moment.

There are reasons EF7 is only usable for simple next-gen ASP.NET apps, and some of the scenarios you mentioned are among those reasons.

I think you're mistaken. Plus it's besides the point.

You can't tell me you couldn't come up with a better way to write DbConnection.GetSchema() that could work in your own apps for .NET Core if you really thought about it. Write it as an extension method on DbConnection and make it work with older versions of the framework by using your own objects. Can't be that hard.

Sometimes GetSchema() is necessary, but it's just an example. You also have GetSchemaTable on a datareader, which is used in a lot more cases (as not everyone reads metadata from a schema), as it tells you what the layout of the resultset is. Essential information for creating datastructures to store resultsets of unknown layout. And yes, that's not in less than 1% of the applications out there. Try most enterprise applications which have to talk to databases with many stored procedures for example. Good luck with writing solid server side code without datatable.

Sure, like I said there's always a way, but the thing is: people will want to port code they already have to .NET core and e.g. run it on Linux. Now they can't do that.

FransBouma avatar Mar 07 '15 09:03 FransBouma

@terrajobst,

Out of curiosity, is there any public information you are using to decide what is important to port or not? Mono used to use Moma to scan and publish a database of "what people really need" to help drive the implementation.

Is there any metric like that being used to help decisions, or is it based more on the direction the team want things to go?

nvivo avatar Mar 07 '15 13:03 nvivo

@FransBouma +1 for the answer. The 1% is totally unrealistic considering that EF showed up in 2011 (2/3 of .Net lifetime are before) and the consideration that DataTable was the dominant technology for data retrieval in all earlier examples. I would more go for 20% to 30% of all enterprise platforms will have dependencies to DataTable (numbers are random as well). Nevertheless, @advancedrei is not completely wrong. He is very right that it is a wrong assumption that the .Net Core will be anytime close a reasonable migration or extension path for existing code. Primary focus are and will be for a while ASP.Net (where the EF is quite dominant in new designs) and .Net Native (which do not rely on local databases but data centers using services) as far as I understand.

@nvivo +1. I totally agree. It is a bit ... in-transparent currently (especially for a Open Source project which expects contributions). @terrajobst Like stated above ... having a forecast what might (DataTable, XmlSchema, etc) and what definitely will be never ever be in (remember the endless .. WPF/WinForms/WebForms discussions) would really be helpful.

tthiery avatar Mar 07 '15 15:03 tthiery

Entity Framework came out of Object Spaces which puts it in the 2008-2009 timeframe. And the 1% I referred to was forward-looking development. How many of those 30% Enterprise projects aren't even on .NET 4.0 yet? I'd venture to say a lot.

NETCORE is not concerned with people who will never migrate anyways. It is concerned with building the next generation of apps. Not maintaining the last one. The Frameworks that have already shipped can handle that just fine.

robertmclaws avatar Mar 07 '15 16:03 robertmclaws

@advancedrei .NET core on Linux could spark new interest in .NET from dev teams who now won't look at .NET as it's windows only but do have lots of databases with stored procs. There are a tremendous amount of database-driven applications out there which have to use stored procs (I use stored procs as an example, as it's one of the use cases for a datatable as the resultsets are often of unknown layout: as you can't determine the layout .... without a datatable ;)) and they can't pick .NET if there's not a solid scenario available for their situation.

There's little known about the ADO.NET story for .NET core, no code in that area is opened yet (to my knowledge) and how the provider model will look like is completely unknown. For server-side software that's an important point, and it now looks like v1.0 of .NET core is completely useless which IMHO wastes a tremendous opportunity to win people back to .NET.

But alas... I'm starting to repeat myself. :)

FransBouma avatar Mar 07 '15 19:03 FransBouma

@tthiery, @terrajobst

Is there any metric like that being used to help decisions?

I'm sorry. I know it sounded like I was questioning the decision, but I was not. =) I was genuinely curious how the process of selecting the API was/is done.

I have been using pure ADO.NET for years without EF, and I have not used DataTable for anything new in ages. I think this can be provided later by a package, but don't need to be in the core right now. We need to remember .NET 4.6 will still be released and all this stuff will be there.

nvivo avatar Mar 07 '15 20:03 nvivo

I'm with others here who point out that we should be looking forward not backward, but... I think we need to be careful here that we don't kill functionality that may be crucial to building applications.

The two things that have jumped out at me are lack of a good story for creating new providers so that third parties have an easy time to create new providers. This (or some other mechanism like standardized DI) is a MUST and currently not supported/documented. Right now you're stuck with SQL Server and third parties can build their own providers but have no effective way to swap providers at runtime (maybe there's something there that we can't see but this was what the provider model was for previously).

Personally I don't see DataTable/DataSet as needed tech, but the features it provides - an easy way to retrieve list based dynamic query DB data is a solid use case for building solutions on top of raw ADO.NET and for third parties that build on top of it. I think something is needed to provide this functionality out of box. It could be as simple as a dictionary, but it should be there natively IMHO because it is a common scenario if you use ADO.NET raw.

So to me the story isn't about backwards compatibility but making sure the use cases that are common are addressed. If that means new interfaces that's fine, as long as some fundamental scenarios that third party tools and frameworks can build on are addressed in some way.

Honestly I think this is all of utmost importance. After all most applications use data. And the story for data in vNext as presented by Microsoft so far looks like a bungling mess. I'm not sure if it actually is or not, but the message has been muddled and confused. From the outside it looks like EF with SQL Server is the only viable solution that's in box and that really sucks if that's how it ends up. Especially in light of .NET Core running on other platforms where SQL Server usage is not very likely. If this is just a messaging thing - then that needs to be corrected with some official commentary. If it's a feature thing then I think there should be discussion on what needs to be there.

RickStrahl avatar Mar 07 '15 22:03 RickStrahl

I agree with @RickStrahl that EF + SqlServer is bad, and agree with @FransBouma that there is no way to do some things like just selecting untyped data without dealing with DataReader. But I don't see anything else filling this gap DataTables left.

What is really to be missed? All the select + order by is done much better by linq directly on objects. For other things, there are alternatives to EF. SimpleData is a famous one, Dapper from StackExchange is also very handy, and even I maintain a pretty useful one =).

I bet new alternatives will appear even more with .NET Core, and eventually a winner will come up. But we need to give it some time.

nvivo avatar Mar 07 '15 22:03 nvivo

I agree with @RickStrahl here. It's the concept / featureset provided by Datatable and friends that's essential, and if I may add, essential for v1.0 to be there. Datatable is an obvious choice to provide that featureset as a truckload of code is already written out there supporting it, but it's not essential to have it as the type to provide that featureset, however why write something else to replace something you already have?

FransBouma avatar Mar 07 '15 22:03 FransBouma

@FransBouma,

Which part exactly do you miss from DataTable? It seems the only thing that you miss is a type that represents "an array of object arrays" for untyped data, but that is provided out of the box.

Is that it or am I missing something?

nvivo avatar Mar 07 '15 22:03 nvivo