我正在用C#语言开发一个软件,它通过调用组织服务与Microsoft Dynamics进行交互。
我只需要更新实体的一些字段,但是当我调用update操作时,Microsoft Dynamics启动了对实体的所有字段的大规模更新。我不想要这个大规模的更新,我只需要更新2或3个字段。
这是我的代码:
//reading account
Entity account = <reading entity with a call to organizationService>
//update fields
account["fieldName1"] = newValue;
account["fieldName2"] = newValue2;
//call to update entity
organizationService.Update(account);我该如何解决这个问题呢?
发布于 2020-01-09 21:40:13
我们在这里使用早期绑定,我们也接受整个对象将被更新,但从内存中:试试这个
var accountToBeSentToDynamics = new Entity("account");
accountToBeSentToDynamics.Id = accountToBeUpdated.Id;
accountToBeSentToDynamics["name"] = "Only This Field will be updated";我们还将这些内容添加到插入或更新列表中,并以1000或更小的批刷新它们,以提高性能
发布于 2020-02-14 05:57:56
这是你的问题。
Entity account = <reading entity with a call to organizationService>;在对org服务的调用中检索到的任何属性都将出现在您的"account“对象上,并随后在更新消息中重新发送给CRM。
尝试如下所示:
Entity retrieved = <reading entity with a call to organizationService>;
Entity account = new Entity("account", retrieved.Id);
//update fields
account["fieldName1"] = newValue;
account["fieldName2"] = newValue2;
//call to update entity
organizationService.Update(account);这样,您就可以确保在CRM中只更新已添加到对象的属性。
最后,在执行检索或RetrieveMultiple时,其最佳实践是仅检索执行业务逻辑所需的属性。更多的属性会降低查询的性能。
https://stackoverflow.com/questions/59664569
复制相似问题