在Microsoft Dynamics CRM(OData)中的单个请求中创建多个实体
发布时间:2020-12-14 05:45:18 所属栏目:Windows 来源:网络整理
导读:我知道如何在单个请求中创建单个实体.但是,有一个要求要我创建多个实体(在我的例子中,它是ContactSet中的多个条目).我尝试将数组放入 POST /XRMServices/2011/OrganizationData.svc/ContactSet [{ "MobilePhone": "+0012 555 555 555","YomiFullName" : "Dem
我知道如何在单个请求中创建单个实体.但是,有一个要求要我创建多个实体(在我的例子中,它是ContactSet中的多个条目).我尝试将数组放入
POST /XRMServices/2011/OrganizationData.svc/ContactSet [{ "MobilePhone": "+0012 555 555 555","YomiFullName" : "Demo User 1","GenderCode" : { "Value" : 1 } ..... <data removed for sanity> ..... },{ "MobilePhone": "+0012 555 555 111","YomiFullName" : "Demo User 2","GenderCode" : { "Value" : 1 } ..... <data removed for sanity> ..... }] 然而,这不起作用,我找不到任何文件解释我实现这一目标的方法.任何帮助将不胜感激. 解决方法
您需要使用
ExecuteMultipleRequest,但我不认为这在Rest服务中可用,但在SOAP服务中可用.
// Get a reference to the organization service. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri,serverConfig.HomeRealmUri,serverConfig.Credentials,serverConfig.DeviceCredentials)) { // Enable early-bound type support to add/update entity records required for this sample. _serviceProxy.EnableProxyTypes(); #region Execute Multiple with Results // Create an ExecuteMultipleRequest object. requestWithResults = new ExecuteMultipleRequest() { // Assign settings that define execution behavior: continue on error,return responses. Settings = new ExecuteMultipleSettings() { ContinueOnError = false,ReturnResponses = true },// Create an empty organization request collection. Requests = new OrganizationRequestCollection() }; // Create several (local,in memory) entities in a collection. EntityCollection input = GetCollectionOfEntitiesToCreate(); // Add a CreateRequest for each entity to the request collection. foreach (var entity in input.Entities) { CreateRequest createRequest = new CreateRequest { Target = entity }; requestWithResults.Requests.Add(createRequest); } // Execute all the requests in the request collection using a single web method call. ExecuteMultipleResponse responseWithResults = (ExecuteMultipleResponse)_serviceProxy.Execute(requestWithResults); // Display the results returned in the responses. foreach (var responseItem in responseWithResults.Responses) { // A valid response. if (responseItem.Response != null) DisplayResponse(requestWithResults.Requests[responseItem.RequestIndex],responseItem.Response); // An error has occurred. else if (responseItem.Fault != null) DisplayFault(requestWithResults.Requests[responseItem.RequestIndex],responseItem.RequestIndex,responseItem.Fault); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Win10系统Cortana 小娜无法搜索
- windows – Vbscript Printscreen到MSpaint
- Windows防火墙netsh阻止文本文件中的所有ips
- xaml – WrapGrid水平滚动Windows 8
- Microsoft Windows上的DisabledByDefault和Enabled SSL / T
- windows – 0x00000077企业服务器上的错误
- PyCharm中导入第三方包
- windows-mobile – 新手机上的Windows Phone 8错误
- pyshark无法在Windows 7(python)上捕获数据包
- 如何在Windows中为Visual Studio项目创建Debian安装包?