1

根据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);

但是在 Dapper 代码中出现异常 “DynamicMethod 的类型所有者无效”

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。

4

0 回答 0