[英]How to retrieve Dynamics CRM 365 data asynchronous on server side
I am implementing an Web API which retrieves data from several Microsoft Dynamics CRM 365, aggregates the data and returns it to the caller. 我正在实现一个Web API,该API从多个Microsoft Dynamics CRM 365检索数据,聚合数据并将其返回给调用方。
I was wondering if it is possible to retrieve the data from the CRM Organization Service asynchronously. 我想知道是否可以异步地从CRM组织服务中检索数据。 Neither the CrmServiceClient nor the ServiceContext generated by the CrmSvcUtil offery async operations. CrmServiceClient或CrmSvcUtil生成的ServiceContext都不提供异步操作。
Is there no possibility to make async crm query calls? 有没有可能进行异步crm查询调用?
Http requests to Xrm.WebApi
are asynchronous by default, eg Xrm.WebApi.retrieveRecord . 默认情况下,对Xrm.WebApi
Http请求是异步的,例如Xrm.WebApi.retrieveRecord 。 Examples in the API document I've linked there are written in JavaScript, but you can of course make Http requests to the WebApi from C# too. 我链接到的API文档中的示例是用JavaScript编写的,但是您当然也可以从C#向WebApi发出Http请求。
This document demonstrates basic CRUD operations to the WebApi using C# and HttpClient.SendAsync()
. 本文档使用C#和HttpClient.SendAsync()
向WebApi演示了基本的CRUD操作。 Extract: 提取:
string connectionString = ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
using (HttpClient client = SampleHelpers.GetHttpClient(
connectionString,
SampleHelpers.clientId,
SampleHelpers.redirectUrl,"v9.0"))
{
Console.WriteLine("--Section 1 started--");
string queryOptions;
contact1.Add("firstname", "Rafel");
contact1.Add("lastname", "Shillo");
HttpRequestMessage createrequest1 = new HttpRequestMessage(HttpMethod.Post,
client.BaseAddress + "contacts");
createrequest1.Content = new StringContent(contact1.ToString());
createrequest1.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
HttpResponseMessage createResponse1 = client.SendAsync(createrequest1,
HttpCompletionOption.ResponseHeadersRead).Result;
if (createResponse1.IsSuccessStatusCode)
{
Console.WriteLine("Contact '{0} {1}' created.", contact1.GetValue("firstname"), contact1.GetValue("lastname"));
contact1Uri = createResponse1.Headers.GetValues("OData-EntityId").FirstOrDefault();
entityUris.Add(contact1Uri);
Console.WriteLine("Contact URI: {0}", contact1Uri);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.