System.Data.Common.DbParameter does not implement IDbDataParameter in an overridable way
System.Data.Common.DbParameter does not implement IDbDataParameter in an overridable way.
Effects: accessing a SqlParameter through the IDbDataParameter interface returns invalid Precision/Scale/Size properties.
Example:
var sql = new SqlParameter();
sql.Precision = 5;
var idb = (IDbDataParameter)sql;
Assert.AreEqual(sql.Precision, idb.Precision); // fails because IDbDataParameter.Precision is hard-coded to 0
In https://github.com/dotnet/corefx/blob/master/src/System.Data.Common/src/System/Data/Common/DbParameter.cs:
byte IDbDataParameter.Precision
{
get { return 0; }
set { }
}
byte IDbDataParameter.Scale
{
get { return 0; }
set { }
}
public virtual byte Precision
{
get { return ((IDbDataParameter)this).Precision; }
set { ((IDbDataParameter)this).Precision = value; }
}
public virtual byte Scale
{
get { return ((IDbDataParameter)this).Scale; }
set { ((IDbDataParameter)this).Scale = value; }
}
In https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs:
public override Byte Scale
{
get
{
return ScaleInternal;
}
set
{
ScaleInternal = value;
}
}
Seems to have been introduced in the .NET core 2.0 branch as part of the IDbDataParameter implementation.
@saurabh500 @corivera this looks like 2.0 blocker ... thoughts?
~~This is a dupe of https://github.com/dotnet/corefx/issues/19708 PR with fix is https://github.com/dotnet/corefx/pull/19961~~ The correct PR is dotnet/corefx#19734 and the issue is dotnet/runtime#21675
To me, it looks like the error is in the DbParameter code.
@saurabh500 I don't see how this is related to the issue/pr you referenced. 19708 is an issue with TVPs and only fixes SqlParameter.
@jonwagner My mistake, I linked the wrong PR and issue. The correct PR is https://github.com/dotnet/corefx/pull/19734 and the issue is https://github.com/dotnet/corefx/issues/19712
Yes, that's the correct duplicate. 👍