-
Notifications
You must be signed in to change notification settings - Fork 286
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
Setting the value DbParameter.DbType to DbType.Time property fails after setting the Value property #5
Comments
This appears to be done for backwards compatibility and is consistent across .NET Framework and Core. You can see the comment in the code at https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs#L326 GetMetaTypeFromDbType returns DateTime for Date, Time, and DateTime: Since it doesn't hurt anything, I image it was to ensure compatibility with pre-SQL 2008 servers, which did not have date or time data types. |
@David-Engel , ok. It is failing actually (I can give the codes with DB Schema if you would like to extend the investigation, so just please let me know). But, since it is purposely made and the developers are aware, then it is there is no point of letting this ticket open. It just happened that when I rewrite some of my DBCommand parameter assignments to compiled-expressions (for performance purposes), then few of my Time and Date related integration tests were failed. So I have to handle it separately as it is really failing when calling the ExecuteNonQuery(). Thanks for the clarity. |
Yes, if you have a scenario it is breaking, please do share the details. Since SQL Server 2008 and older are no longer supported, I can see us considering changing the functionality. |
Wow, this is great. I will upload it here soon or maybe link a reference to a project with everything you need. |
The project solution is located here: https://github.com/mikependon/SqlClient/tree/master/Issue5 Note: I replicated the issue #7 at NetFramework, so please use the NetCore project instead to replicate this issue. |
It hurts. Setting a parameter to
This throws There is a work-around: setting the Yes it is consistent with .Net Framework System.Data.SqlClient, but since Microsoft.Data.SqlClient is about not getting crippled with old legacies as far as I understand it, it should not keep this behavior. |
@cheenamalhotra Is this "up for grabs" ? Considering giving it a go. |
Sure! It would be nice to have this one fixed if anyone is willing to contribute! |
Breaks support for SQL Server 2008 (I believe) fixes dotnet#5
Related issues for reference: |
* Get and set expected value for DdType.Date and DbType.Time Breaks support for SQL Server 2008 (I believe) fixes #5 Extend DateTimeTest.ReaderParameterTest to cover DbType parameters
* Get and set expected value for DdType.Date and DbType.Time Breaks support for SQL Server 2008 (I believe) fixes #5 Extend DateTimeTest.ReaderParameterTest to cover DbType parameters
* Get and set expected value for DdType.Date and DbType.Time Breaks support for SQL Server 2008 (I believe) fixes dotnet#5 Extend DateTimeTest.ReaderParameterTest to cover DbType parameters
* Get and set expected value for DdType.Date and DbType.Time Breaks support for SQL Server 2008 (I believe) fixes dotnet#5 Extend DateTimeTest.ReaderParameterTest to cover DbType parameters
* Add event counters * Add support netstandard 2.1 & fix the conflict in event source * Support new event source types & add the test unit * Remove supporting obsolete types * fix unit test * Add snippet sample code * Address comments * Fix minor typo (#3) * Reformatting counter methods * Fix minor typo * Removed IsEnabled condition and reformatted counter methods * Unit tests for Microsoft.Data.SqlClient.SqlClientEventSource (#2) * Implemented tests for Microsoft.Data.SqlClient.SqlClientEventSource * Updated the EventCounter test to reflect the recent changes in the code * Working on EventCounter tests access event counters through reflection * Updated the EventCounterTest to use reflection * Fixing dangling SqlConnection's left in tests * EventCountersTest now checks hard/soft connects/disconnects counters * Reverted the DataTestUtility changes * Reverted using statements to the old-style in tests * Reverted the ConnectionPoolTest.ReclaimEmancipatedOnOpenTest() * Reverted using statements to the old-style in tests * Reverted using statements to the old-style in tests * Rewrite the EventCounterTest assertions not to conflict with other tests * Code review cleanup * Add more tests (#5) Added EventCounter_ReclaimedConnectionsCounter_Functional & EventCounter_ConnectionPoolGroupsCounter_Functional tests. * Address comments Co-authored-by: Davoud Eshtehari <David.esh@gmail.com> Co-authored-by: Davoud Eshtehari <v-daesht@microsoft.com> Co-authored-by: Karina Zhou <v-jizho2@microsoft.com> Co-authored-by: Nikita Kobzev <win.accuracy@gmail.com>
Describe the bug
Setting the value DbParameter.DbType to DbType.Time property is failing after setting the Value property
No exception and not a breaking issue.
To reproduce
Expected behavior
I would expect that after setting the
DbParameter.DbType
property toDbType.Time
, the the value of theDbParameter.DbType
property should beDbType.Time
(notDbType.DateTime
).Further technical details
#region Assembly Microsoft.Data.SqlClient, Version=1.0.19128.1, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5
// C:\Users\MIPEN.nuget\packages\microsoft.data.sqlclient\1.0.19128.1-preview\ref\netcoreapp2.1\Microsoft.Data.SqlClient.dll
#endregion
Additional context
Explained in the code above.
The text was updated successfully, but these errors were encountered: