int iSuccess = 0; int iFaile = 0; var adminService = CrmServiceClientCommon.GetService(); // 创建QueryExpression对象 QueryExpression query = new QueryExpression("opportunity"); // 创建LinkEntity对象,连接到"PrincipalObjectAccess"表 LinkEntity link = new LinkEntity("opportunity", "principalobjectaccess", "opportunityid", "objectid", JoinOperator.Inner); // 创建条件:团队ID等于特定值 link.LinkCriteria.AddCondition("principalid", ConditionOperator.Equal, new Guid("F3EFA9E3-3B0D-EF11-9F8A-6045BD557A70")); // 将LinkEntity添加到QueryExpression对象 query.LinkEntities.Add(link); // 执行查询并获取结果 EntityCollection results = adminService.RetrieveMultiple(query); foreach (var en in results.Entities) { //取消共享 var request = new RevokeAccessRequest { Revokee = new EntityReference("team", new Guid("F3EFA9E3-3B0D-EF11-9F8A-6045BD557A70")), Target = en.ToEntityReference() }; try { adminService.Execute(request); iSuccess++; } catch (Exception ex) { iFaile++; } Console.Write($"总数{results.Entities.Count},成功{iSuccess},失败{iFaile}\n"); }
标签:Team,QueryExpression,results,LinkEntity,query,online,new,共享 From: https://www.cnblogs.com/parkerchen/p/18334964