Commit 5039ea1c authored by Marc Gravell's avatar Marc Gravell

Issue 130: don't try to convert to object

parent 621e7375
......@@ -1299,7 +1299,7 @@ private static IEnumerable<T> QueryImpl<T>(this IDbConnection cnn, CommandDefini
object val = func(reader);
if (effectiveType == typeof(object))
{
yield return (T)Convert.ChangeType(val, effectiveType);
yield return (T)(object)val;
} else if (val == null || val is T) {
yield return (T)val;
} else {
......
......@@ -3146,6 +3146,21 @@ public void SO24740733_TestCustomValueSingleColumn()
foo.Value.IsEqualTo(200);
}
public void Issue130_IConvertible()
{
dynamic row = connection.Query("select 1 as [a], '2' as [b]").Single();
int a = row.a;
string b = row.b;
a.IsEqualTo(1);
b.IsEqualTo("2");
row = connection.Query<dynamic>("select 3 as [a], '4' as [b]").Single();
a = row.a;
b = row.b;
a.IsEqualTo(3);
b.IsEqualTo("4");
}
#if POSTGRESQL
class Cat
......
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