janjosephlim / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Dapper 1.13 introduces bug to dynamic types #143

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have code that looks like the following:

var data = connection.Query(sql);
foreach (dynamic row in data)
{
    row.NewDynamicProperty = 5;
}

Since the type returned is dynamic, I expect to be able to add my own property 
on the fly. This worked in Dapper 1.12, but not in the 1.13 release. The 
exception thrown is:

Exception type: ArgumentException 
Exception message: Incorrect number of arguments supplied for call to method 
'System.Object SetValue(System.String, System.Object, Boolean)'
at System.Linq.Expressions.Expression.ValidateArgumentCount(MethodBase method, 
ExpressionType nodeKind, Int32 count, ParameterInfo[] pis)
at System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, 
ExpressionType nodeKind, ReadOnlyCollection`1& arguments)
at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo 
method, IEnumerable`1 arguments)
at Dapper.SqlMapper.DapperRowMetaObject.BindSetMember(SetMemberBinder binder, 
DynamicMetaObject value)
at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, 
ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, 
Object[] args)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, 
T0 arg0, T1 arg1)

Original issue reported on code.google.com by br...@vallelunga.com on 28 Jun 2013 at 1:41

GoogleCodeExporter commented 8 years ago
Yep, got it too. DapperRow now "typed" in DapperTable, so no new members 
possible in this "dynamic".

Original comment by azh...@gmail.com on 4 Jul 2013 at 12:23

GoogleCodeExporter commented 8 years ago
This binding only fails on primitive types. Consider wrapping to object as work 
around.

Original comment by azh...@gmail.com on 8 Jul 2013 at 2:10

GoogleCodeExporter commented 8 years ago
I plan on looking into this issue this week. No breaking change was intended.

Original comment by marc.gravell on 8 Jul 2013 at 5:11

GoogleCodeExporter commented 8 years ago
I'm also getting breakage around this.
A fix will be great.

Original comment by d...@houmus.org on 15 Jul 2013 at 12:59

GoogleCodeExporter commented 8 years ago
I´m also having the same problem. 

Original comment by dieg...@lynkos.com on 18 Oct 2013 at 5:09

GoogleCodeExporter commented 8 years ago
Are there any news about this?

Original comment by d...@houmus.org on 19 Nov 2013 at 6:15