-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SqlDateTime2 #46127
Comments
Tagging subscribers to this area: @cheenamalhotra, @David-Engel Issue DetailsDescriptionMy own and other people's performance tests show that that SqlTypes can give better performance that using the built in .NET types. dotnet/SqlClient#846 In sql client specifically, calling GetDateTime vs GetSqlDateTime and similar "pairs" of methods. The performance gain from using SqlTypes and their GetSqlWhatever method comes from not having to call IsDbNull on SqlDataReader. I found this issue when profiling and IsDbNull stuck its head out, then I tried using GetSqlDateTime, since it handles null internally - but that struct does not support DATETIME2 - so I am stuck with using IsDbNull+GetDateTime. So I propose that you add a SqlDateTime2 struct to make the "API" complete. It seems like this was forgotten when DATETIME2 was introduced into SQL Server - unless the SqlTypes are legacy and not meant for new development? Having a SqlDateTime2 struct makes it possible to implement a GetSqlDateTime2 method in "sql client". An alternative would also be to "fix" SqlDateTime - so it also handles the extended range of DATETIME2 - but that would potentially be a breaking change for some applications.
|
This would be in System.Data. @roji - Do you know any of the history about why some data types like datetime2, introduced in SQL Server 2008, did not get their own SqlType while they did get their own DbType and SqlDbType? My guess is it may have to do with other ADO.NET data providers and backwards compatibility... |
Or, it could be put into Micsoft.Data.SqlClient if that's the only place that would use it. As far as i know the reason that the other SqlTypes are still in runtime is that DataTable uses them so if it were put into runtime would that also include adding these types to DataTable DataAdapter etc? @roji and I discussed this somewhat at dotnet/SqlClient#846 and I thought that those types were supported but not actively being considered for new development, EF and other ORM's have largely replaced them. |
Tagging subscribers to this area: @roji, @ajcvickers Issue DetailsDescriptionMy own and other people's performance tests show that that SqlTypes can give better performance than using the built in .NET types. dotnet/SqlClient#846 In sql client specifically, calling GetDateTime vs GetSqlDateTime and similar "pairs" of methods. The performance gain from using SqlTypes and their GetSqlWhatever method comes from not having to call IsDbNull on SqlDataReader. I found this issue when profiling and IsDbNull stuck its head out, then I tried using GetSqlDateTime, since it handles null internally - but that struct does not support DATETIME2 - so I am stuck with using IsDbNull+GetDateTime. So I propose that you add a SqlDateTime2 struct to make the "API" complete. It seems like this was forgotten when DATETIME2 was introduced into SQL Server - unless the SqlTypes are legacy and not meant for new development? Having a SqlDateTime2 struct makes it possible to implement a GetSqlDateTime2 method in "sql client". An alternative would also be to "fix" SqlDateTime - so it also handles the extended range of DATETIME2 - but that would potentially be a breaking change for some applications.
|
Closing in favor of dotnet/SqlClient#846, and the move to implement there instead of in the runtime. To summarize the current situation:
|
Description
My own and other people's performance tests show that that SqlTypes can give better performance than using the built in .NET types. dotnet/SqlClient#846
In sql client specifically, calling GetDateTime vs GetSqlDateTime and similar "pairs" of methods.
The performance gain from using SqlTypes and their GetSqlWhatever method comes from not having to call IsDbNull on SqlDataReader.
I found this issue when profiling and IsDbNull stuck its head out, then I tried using GetSqlDateTime, since it handles null internally - but that struct does not support DATETIME2 - so I am stuck with using IsDbNull+GetDateTime.
So I propose that you add a SqlDateTime2 struct to make the "API" complete. It seems like this was forgotten when DATETIME2 was introduced into SQL Server - unless the SqlTypes are legacy and not meant for new development?
Having a SqlDateTime2 struct makes it possible to implement a GetSqlDateTime2 method in "sql client".
An alternative would also be to "fix" SqlDateTime - so it also handles the extended range of DATETIME2 - but that would potentially be a breaking change for some applications.
The text was updated successfully, but these errors were encountered: