-
Notifications
You must be signed in to change notification settings - Fork 314
Closed
Labels
Enhancement 💡Issues that are feature requests for the drivers we maintain.Issues that are feature requests for the drivers we maintain.Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the labelIssues that are ready to be picked up for anyone interested. Please self-assign and remove the label
Milestone
Description
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
using Microsoft.Data.SqlClient;
using System;
using System.Data;
namespace DbParameterDbTypeTimeTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
TestDbTypeTimeAssignment();
Console.ReadLine();
}
static void TestDbTypeTimeAssignment()
{
using (var connection = new SqlConnection(""))
{
using (var command = connection.CreateCommand())
{
var parameter = command.CreateParameter();
parameter.ParameterName = "ParameterName";
// Here I first set the value of the parameter to any TimeStamp
parameter.Value = DateTime.UtcNow.TimeOfDay;
// After I assign the value at line 26, the DbType property is "AUTOMATICALLY"
// set to DbType.Time.
// The issue is below, I have an explicit call on my ORM to set the DbParameter.DbType
// value to DbType.Time, and the result afterwards is DbType.DateTime
parameter.DbType = DbType.Time;
command.Parameters.Add(parameter);
}
}
}
}
}
Expected behavior
I would expect that after setting the DbParameter.DbType
property to DbType.Time
, the the value of the DbParameter.DbType
property should be DbType.Time
(not DbType.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.
Metadata
Metadata
Assignees
Labels
Enhancement 💡Issues that are feature requests for the drivers we maintain.Issues that are feature requests for the drivers we maintain.Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the labelIssues that are ready to be picked up for anyone interested. Please self-assign and remove the label