连接角色不相关

时间:2013-04-30 17:16:10

标签: c# dynamics-crm-2011

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

当我尝试保存时,我收到错误"连接角色不相关"。我对此错误的看法不多。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

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