Dapper:多次执行命令,linq和ToArray

时间:2012-01-02 21:05:41

标签: .net dapper

根据dapper docs,可以写

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 } }
    )

我尝试使用

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

但得到例外     “DynamicMethod的无效类型所有者” 在Dapper代码中

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);
    ...

我是在尝试编写过于聪明的代码还是我误解了其他内容?偶然发现了一个错误?

我在Win7上运行Dotnet3.5。

0 个答案:

没有答案