1
XrmServiceContext       xrmSvc      = null;
xrmSvc = new XrmServiceContext("http://mycrmwebdev/CRMDev")
Connection cnctn = xrmSvc.ConnectionSet.Where(c => c.ConnectionId == "3D2BC21F-6D8F-E211-9F0F-1CC1DE248972").First();

if (cnctn != null) {
    CrmEntityReference rec1RoleId = new CrmEntityReference {
        LogicalName = ConnectionRole.EntityLogicalName,
        Name = "Record1RoleId",
        Id = new Guid("B818399C-E766-E111-A1B1-00155D0A6B13")
    };

    CrmEntityReference rec2RoleId = new CrmEntityReference {
        LogicalName = ConnectionRole.EntityLogicalName,
        Name = "Record2RoleId",
        Id = new Guid("B818399C-E766-E111-A1B1-00155D0A6B13")
    };

    cnctn.Record1RoleId = rec1RoleId;
    cnctn.Record2RoleId = rec2RoleId;

    xrmSvc.UpdateObject(cnctn);

    //Error occurs here
    xrmSvc.SaveChanges();
}

当我尝试保存时,出现错误“连接角色不相关”。我没有看到太多关于这个错误的信息。有任何想法吗?

4

1 回答 1

2

由于 CRM 中的 Connections 表中存在相互关系,因此请确保只更新一条记录。CRM 将处理更新互惠记录。

于 2013-04-30T18:07:03.910 回答