提交 8d65caba 编写于 作者: M Marc Gravell

Investigate failing test: Scale/Precision is broken SqlClient (issue 1612 logged)

上级 ec6faf54
......@@ -4771,10 +4771,7 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
p.Size = DbString.DefaultLength;
}
}
if (param.Size != null)
{
p.Size = param.Size.Value;
}
if (param.Size != null) p.Size = param.Size.Value;
if (param.Precision != null) p.Precision = param.Precision.Value;
if (param.Scale != null) p.Scale = param.Scale.Value;
}
......@@ -4782,6 +4779,8 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
{
if (dbType != null) p.DbType = dbType.Value;
if (param.Size != null) p.Size = param.Size.Value;
if (param.Precision != null) p.Precision = param.Precision.Value;
if (param.Scale != null) p.Scale = param.Scale.Value;
handler.SetValue(p, val ?? DBNull.Value);
}
......
......@@ -44,7 +44,7 @@
}
},
"dnxcore50": {
"compilationOptions": { "define": [ ], "warningsAsErrors": true },
"compilationOptions": { "define": [ ], "warningsAsErrors": true },
"dependencies": {
"System.Text.RegularExpressions": "4.0.10-beta-*",
"System.Collections": "4.0.10-beta-*",
......
......@@ -58,7 +58,11 @@ static void RunPerformanceTests()
static void Main()
{
#if DNXCORE50
Console.WriteLine("CoreCLR");
#else
Console.WriteLine(Environment.Version);
#endif
#if DEBUG
RunTests();
#else
......
......@@ -4337,6 +4337,60 @@ public void Issue261_Decimals()
c.IsEqualTo(11.884M);
}
public void Issue261_Decimals_ADONET_SetViaBaseClass()
{
Issue261_Decimals_ADONET(true);
}
public void Issue261_Decimals_ADONET_SetViaConcreteClass()
{
Issue261_Decimals_ADONET(false);
}
private void Issue261_Decimals_ADONET(bool setPrecisionScaleViaAbstractApi)
{
try
{
using (var cmd = connection.CreateCommand())
{
cmd.CommandText = "create proc #Issue261Direct @c decimal(10,5) OUTPUT as begin set @c=11.884 end";
cmd.ExecuteNonQuery();
}
}
catch { /* we don't care that it already exists */ }
using (var cmd = connection.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "#Issue261Direct";
var c = cmd.CreateParameter();
c.ParameterName = "c";
c.Direction = ParameterDirection.Output;
c.Value = DBNull.Value;
c.DbType = DbType.Decimal;
if (setPrecisionScaleViaAbstractApi)
{
#if DNXCORE50
DbParameter baseParam = c;
#else
IDbDataParameter baseParam = c;
#endif
baseParam.Precision = 10;
baseParam.Scale = 5;
}
else
{
c.Precision = 10;
c.Scale = 5;
}
cmd.Parameters.Add(c);
cmd.ExecuteNonQuery();
decimal value = (decimal)c.Value;
value.IsEqualTo(11.884M);
}
}
public void BasicDecimals()
{
var c = connection.Query<decimal>("select @c", new { c = 11.884M }).Single();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册