替换关联实体
Replace associated entities
我正在为 Dynamics 365 使用 Microsoft.Xrm.Sdk。
假设我有一个实体 Movie 和 Tag。一部电影有多个标签。
让我们associate将标签 A 和 B 添加到电影 X。
EntityReferenceCollection tags = new EntityReferenceCollection();
tags.Add(new EntityReference("tag", "A"));
tags.Add(new EntityReference("tag", "B"));
svc.Associate("movie", "X", new Relationship("movie_tag"), tags);
现在假设我需要 link 新标签
如何用新标签替换这些标签?
我是否必须检索已经关联的标签,disassociate 一个一个地检索它们,然后关联新标签?
是的,你需要 "retreive the already associated tags, disassociate them one by one, and associate the new ones"。
请注意,您取消关联也需要一个集合,因此您可以在一次调用中删除多个。
我正在为 Dynamics 365 使用 Microsoft.Xrm.Sdk。
假设我有一个实体 Movie 和 Tag。一部电影有多个标签。
让我们associate将标签 A 和 B 添加到电影 X。
EntityReferenceCollection tags = new EntityReferenceCollection();
tags.Add(new EntityReference("tag", "A"));
tags.Add(new EntityReference("tag", "B"));
svc.Associate("movie", "X", new Relationship("movie_tag"), tags);
现在假设我需要 link 新标签
如何用新标签替换这些标签?
我是否必须检索已经关联的标签,disassociate 一个一个地检索它们,然后关联新标签?
是的,你需要 "retreive the already associated tags, disassociate them one by one, and associate the new ones"。
请注意,您取消关联也需要一个集合,因此您可以在一次调用中删除多个。