1

According to the dapper docs one can write

connection.Execute(@"insert into MyTable(colA, colB) values (@a, @b)",
    new[] { new { a=1, b=1 }, new { a=2, b=2 }, new { a=3, b=3 } }
    )

I tried using

conn.Execute(
    @"
    insert into RelRoleUser ( RoleID, UserID )
    values( @roleID, @userID )",
    userroleList.Select(r => new { roleID = r.roleID, userID = r.userID }).ToArray(),
    null, null, null);

But get an exception "Invalid type owner for DynamicMethod" in Dapper code

private static Action<IDbCommand, object> CreateParamInfoGenerator(Type type)
    {
    var dm = new DynamicMethod(string.Format("ParamInfo{0}", Guid.NewGuid()), null,     new[] { typeof(IDbCommand), typeof(object) }, type, true);
    ...

Am I trying to write too clever code or have I misunderstood something else? Stumbled upon a bug?

I am running Dotnet3.5 on Win7.

Stuart.Sklinar
  • 3,683
  • 4
  • 35
  • 89
LosManos
  • 7,195
  • 6
  • 56
  • 107
  • can you retest on .net 4, I wonder if this is platform specific see: http://code.google.com/p/dapper-dot-net/source/browse/Tests/Tests.cs#261 – Sam Saffron Jan 04 '12 at 03:29
  • I played around in dotnet4 and could use both IEnumerable and List and everything worked as expected. I drop the case since my customers are moving to dotnet4 anyway and looping solved the dotnet3.5 case. – LosManos Jan 07 '12 at 11:39
  • 2
    ok, this now makes sense, must be a bug in dapper targeted at 3.5. we will sort it out – Sam Saffron Jan 07 '12 at 22:00
  • 2
    To echo @Sam - yeah, will fix. Darned Compatibility! – Marc Gravell Jan 07 '12 at 22:37

0 Answers0