仅更新 Microsoft Dynamics 实体中的某些字段
Update only some fields in a Microsoft Dynamics entity
我正在用 C# 语言开发一个软件,它通过调用组织服务与 Microsoft Dynamics 进行交互。
我只需要更新实体的某些字段,但是当我调用更新操作时,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);
我该如何解决这个问题?
我们在这里使用早期绑定,我们也接受整个对象将被更新,但是从内存中:
试试这个
var accountToBeSentToDynamics = new Entity("account");
accountToBeSentToDynamics.Id = accountToBeUpdated.Id;
accountToBeSentToDynamics["name"] = "Only This Field will be updated";
我们还将这些添加到插入或更新列表中,并以大小为 1000 或更小的批次刷新它们以提高性能
这是你的问题。
Entity account = <reading entity with a call to organizationService>;
在组织服务调用中检索到的任何属性都将出现在您的 "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 中更新。
最后,最佳做法是在执行 Retrieve 或 RetrieveMultiple 时仅检索执行业务逻辑所需的属性。更多的属性会降低查询的性能。
我正在用 C# 语言开发一个软件,它通过调用组织服务与 Microsoft Dynamics 进行交互。
我只需要更新实体的某些字段,但是当我调用更新操作时,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);
我该如何解决这个问题?
我们在这里使用早期绑定,我们也接受整个对象将被更新,但是从内存中: 试试这个
var accountToBeSentToDynamics = new Entity("account");
accountToBeSentToDynamics.Id = accountToBeUpdated.Id;
accountToBeSentToDynamics["name"] = "Only This Field will be updated";
我们还将这些添加到插入或更新列表中,并以大小为 1000 或更小的批次刷新它们以提高性能
这是你的问题。
Entity account = <reading entity with a call to organizationService>;
在组织服务调用中检索到的任何属性都将出现在您的 "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 中更新。
最后,最佳做法是在执行 Retrieve 或 RetrieveMultiple 时仅检索执行业务逻辑所需的属性。更多的属性会降低查询的性能。