igor-tkachev/bltoolkit — Issue #56: DbManager.AssignParameterValues bug
Author: lvv83
Created: 2011-10-16 17:15:57+00:00
State: open

AssignParameterValues(object) doesn't assign defaut value of nullable property to the parameter. To reproduce this bug you may use this unit test

public class DataTypeTest2
{
[MapField("DataTypeID")]
public int ID;

public Single? Single_ { get; set; }
}

[TestFixture]
public class DbManagerTest
{
//...
#if MSSQL
[Test]
#endif
public void AssignParameterValuesTest()
{
string connectionString = DbManager.GetConnectionString(null);

DataTypeTest2 obj = new DataTypeTest2 { Single_ = 0F };

using (DbManager db = new DbManager(new SqlConnection(connectionString)))
{
db.SetCommand("INSERT INTO DataTypeTest (Single_) VALUES (@Single_)", db.Parameter("@Single_", 1.5F, DbType.Single));
db.AssignParameterValues(obj);
Assert.AreEqual(obj.Single_, db.Parameter("@Single_").Value);
}
}
}