System.Data in .NET Core 3.0

System.Data in .NET Core 3.0

While it doesn’t get a lot of attention,&nbsp;<a href="https://github.com/dotnet/corefx/issues?utf8=%E2%9C%93&amp;q=label:area-System.Data+milestone:3.0+" target="_blank">System.Data</a>&nbsp;is crucial for any sort of relational database access in .NET. Also known as ADO.NET in honor of its predecessor, ActiveX Data Objects, System.Data provides a generic framework upon which .NET database drivers can be built. This framework provides for certain conventions database drivers are expected to adhere to.

While it doesn’t get a lot of attention, System.Data is crucial for any sort of relational database access in .NET. Also known as ADO.NET in honor of its predecessor, ActiveX Data Objects, System.Data provides a generic framework upon which .NET database drivers can be built. This framework provides for certain conventions database drivers are expected to adhere to.

Connections, commands, and data readers are all based on a dual inheritance scheme. Each inherits some basic functionality from DbConnection, DbCommand, and DbDataReader respectively. They also implement the abstract interfaces IDbConnection, IDbCommand, and IDbDataReader, which allows for mocking scenarios and non-traditional data sources. This dual inheritance scheme is also used for all of the base classes described below.

While connection strings are normally thought of as strings, facilities exist for representing them as objects that inherit from DbConnectionStringBuilder. This handles database specific parsing of connection strings and gives the developer a better idea of what settings are available for a particular database.

System.Data predates ORMs for .NET, but it does offer a generic way to generate SQL via implementations of the DbDataAdapter and DbCommandBuilder classes. This was used both directly and in conjunction with normal and typed DataSets.

If you are looking for a real-world example of the abstract factory pattern, look at the DbProviderFactory. Subclasses of this provide connections, commands, command parameters, command builders, and data adapters. Essentially everything you need for data access without the need for database specific logic.

The Problem with Interfaces

As mentioned above, System.Data relies on dual inheritance. This can be a problem when adding new methods. For example, asynchronous operations were added to DbCommand in .NET 4.5. However, they could not be added to the matching IDbCommand interface because that would be a breaking change. Which in turn means you cannot use both asynchronous operations and the easily mocked abstract interface at the same time.

Microsoft could have done a one-time reset of the abstract interfaces in .NET Core 1.0 so they match the abstract classes. (Java has done this in the past with JDBC interfaces.) However, that would make sharing code with .NET Framework difficult.

If default interface methods make it into C# 8, then in theory they could be used to realign the interfaces in a backwards compatible manner. But again, that wouldn’t be compatible with .NET Framework since default interface methods is a .NET Core only feature. Nor would it work with older compilers and other .NET languages.

String Overloads for DbDataReader.Get*() #31595

Our first .NET Core 3.0 feature is the ability to pass a column name to the DbDataReader.GetXXX methods. A long-time complaint about this interface is you cannot refence columns by name. Which means instead you need to use this pattern:

reader.GetInt32(reader.GetOrdinal("columnName"))

An obvious (and to some, long overdue) simplification is to offer a string overload.

reader.GetInt32("columnName")

This has already been done in Oracle's Connector/NET and MySqlConnector.

For performance reasons this new method will not be marked as virtual, allowing the JIT compiler to easily inline it. And for the reasons mentioned above, the new set of methods will not be added to IDbDataReader.

XmlDataDocument #33442

If you know the history of XmlDataDocument, this may seem like an odd pick. It has been marked as obsolete with the warning 'XmlDataDocument class will be removed in a future release.' since .NET 4.0 was released in 2010.

The reason it is being picked up now is some WinForms and WPF applications use it. The bug report says, “This has 1-7% of usage in various categories from Apiport.”

DatasetExtensions

One feature that won’t be made available in .NET Core 3 is DataTableExtensionsclass. While it appears to be fairly simple with only 6 extension methods, the AsDataView cannot be built without modifications to System.Data itself. The reasoning is fairly complex, having to do with internal methods, type forwarding, and the challenges posed by .NET Standard.

If you are interested, the relevant conversations are Port DatasetExtensions to .NET Core #19771Port DataTable.AsDataView extension methods #27610, and Exposing internal virtuals involving searching a key in DataView #31764.

.net

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

ML.NET Model Builder is now a part of Visual Studio | .NET Blog

ML.NET is a cross-platform, machine learning framework for .NET developers. Model Builder is the UI tooling in Visual Studio that uses Automated Machine Learning (AutoML) to train and consume custom ML.NET models in your .NET apps. You can use ML.NET and Model Builder to create custom machine learning models without having prior machine learning experience and without leaving the .NET ecosystem.

Hire ASP.Net Developers

Looking to outsource your asp dot net development requirement? ASP.Net is a special feature of the DOT Net framework created by Microsoft. At [HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io"), we have a team of experienced...

.NET Core .NET Framework|teratail

前提・実現したいこと.NET Coreから.NET Frameworkへの移植 発生している問題・エラーメッセージ「.NET Framework」から「.NET Core」の移植方法については方法が見つかったのですがその逆はなかなか見つからず。。。

Announcing .NET 5 Preview 4 and our journey to one .NET | .NET Blog

.NET 5 is the next version and future of .NET. We are continuing the journey of unifying the .NET platform, with a single framework that extends from cloud to desktop to mobile and beyond. Looking back, we took the best of .NET Framework and put that into .NET Core 3,

Performance Improvements in .NET 5 | .NET Blog

In previous releases of .NET Core, I’ve blogged about the significant performance improvements that found their way into the release. For each post, from .NET Core 2.0 to .NET Core 2.1 to .NET Core 3.0, I found myself having more and more to talk about.