Dynamics 365组织服务中的批量操作

参考原文:

https://learn.microsoft.com/en-us/power-apps/developer/data-platform/bulk-operations?tabs=sdk

总结版本

一次只能批量创建/更新同一个实体的不同记录,不同的还是得走多个。待验证。

生效的版本是线上版本,9.0的sdk不带这个。

upsert是个丑东西。

CreateMultipleRequest createMultipleRequest = new() { Targets = entities, };

service.CreateMultiple(createMultipleRequest)

UpdateMultipleRequest updateMultipleRequest = new() { Targets = entities, };

service.UpdateMultiple(updateMultipleRequest )

 

UpsertMultiple

service.Create(new Entity(tableLogicalName) { Attributes = { {altKeyColumnLogicalName, "Record For Update"}, {"samples_description","A record to update using Upsert" } } }); // Using the Entity constructor to specify alternate key Entity toUpdate = new( entityName: tableLogicalName, keyName: altKeyColumnLogicalName, // Same alternate key value as created record. keyValue: "Record For Update"); toUpdate["samples_description"] = "Updated using Upsert"; Entity toCreate = new( entityName: tableLogicalName, keyName: altKeyColumnLogicalName, keyValue: "Record For Create"); toCreate["samples_description"] = "A record to create using Upsert"; // Add the records to a collection EntityCollection records = new() { EntityName = tableLogicalName, Entities = { toUpdate, toCreate } }; // Send the request UpsertMultipleRequest request = new() { Targets = records }; var response = (UpsertMultipleResponse)service.Execute(request);

posted @ 2024-08-27 17:23  正则月  阅读(54)  评论(0)    收藏  举报