Commit 9ac9c401 authored by Marc Gravell's avatar Marc Gravell

Nulls in dynamic

parent 36f51540
......@@ -1550,13 +1550,16 @@ public object SetValue(string key, object value)
if (startBound == 0)
{
r.GetValues(values);
for (int i = 0; i < values.Length; i++)
if (values[i] is DBNull) values[i] = null;
}
else
{
var begin = returnNullIfFirstMissing ? 1 : 0;
for (var iter = begin; iter < effectiveFieldCount; ++iter)
{
values[iter] = r.GetValue(iter + startBound);
object obj = r.GetValue(iter + startBound);
values[iter] = obj is DBNull ? null : obj;
}
}
return new DapperRow(table, values);
......
......@@ -555,6 +555,8 @@ class TestObj
public int _priv;
private int Priv { set { _priv = value; } }
private int PrivGet { get { return _priv;} }
}
public void TestSetInternal()
......@@ -567,6 +569,17 @@ public void TestSetPrivate()
connection.Query<TestObj>("select 10 as [Priv]").First()._priv.IsEqualTo(10);
}
public void TestExpandWithNullableFields()
{
var row = connection.Query("select null A, 2 B").Single();
((int?)row.A)
.IsNull();
((int?)row.B)
.IsEqualTo(2);
}
public void TestEnumeration()
{
var en = connection.Query<int>("select 1 as one union all select 2 as one", buffered: false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment