ASP vNext Core 5.0 DataTable

我的未来我决定 提交于 2019-12-24 04:27:25

问题


Is it possible to use the 'DataTable' or 'DataSet' classes in ASP vNext Core 5.0?

When I try to use those classes, I am getting the error:

'The type or namespace name 'DataTable' could not be found'.


回答1:


This question is a few months old but I see it coming up all the time so I'll post an answer.

As of beta 3, aspnetcore contains only a subset of the System.Data related members, which can be referenced in System.Data.SqlClient, and System.Data.Common. Among the more noticeable items missing from the data libraries are the following: DataTable, DataSet, IDbConnection, IDbCommand, IDbTransaction, and IDbDataParameter and IDataReader.

If you're looking to maintain some abstraction, you can reference the associated abstract classes like DbCommand, DbConnection, DbTransaction and DbDataReader. One thing to note, DbDataReader along with the SqlDbDataReader object no longer support the Close() method. Instead, you'll just call dispose.

I have not heard whether or not these members will be reintroduced in aspnetcore or not, but they don't appear to be in beta 4 either.




回答2:


aspnetcore is subset of dnxcore and is considered deprecated, one should use dnxcore instead.

As for the DataTables and other related System.Data types, according to this issue they aren't going to include it soon, unfortunately.




回答3:


Classes DataSet/DataTable/DataRow and everything related to them (DbCommandGenerator, DbDataAdapter etc) are not available in .NET Core 1.0 release (and in .NET Standards 1.3-1.6 specifications as well). This means that ADO.NET was reduced to minimalistic set of low-level interfaces and components (like IDbConnection, IDbCommand, IDbTransaction, DbProviderFactory). At this moment there are no confirmation that DataRow/DataTable will back in future .NET Core releases.

If you're looking for something between low-level .NET Core ADO interfaces and strongly-typed EF Core models - take a look to open-source NReco.Data library that provides alternative implementations for DbCommandGenerator and DbDataAdapter. I'm the author of this library, so you can ask me for details.



来源:https://stackoverflow.com/questions/27900493/asp-vnext-core-5-0-datatable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!