C# 使用asp.net core 3.0中的CRM 2011 REST数据
我需要在Blazor应用程序(在.net Core 3.0中新增)中使用CRM 2011数据。 .net核心不再支持SOAP。因此,我们正在寻找关于如何使用REST端点的示例 Microsoft SDK程序集都使用WCF for SOAP端点,这在.net core中不受支持。因此,我不得不使用REST端点。我只需要基本的积垢操作 我尝试使用uncase-OData-Connectedservice()生成了一些代码。然而,所有的例子都只展示了如何添加服务,但还没有找到任何关于如何使用它的文档? 它也无法完成以下错误: 感谢您的帮助或建议。C# 使用asp.net core 3.0中的CRM 2011 REST数据,c#,.net-core,odata,dynamics-crm-2011,C#,.net Core,Odata,Dynamics Crm 2011,我需要在Blazor应用程序(在.net Core 3.0中新增)中使用CRM 2011数据。 .net核心不再支持SOAP。因此,我们正在寻找关于如何使用REST端点的示例 Microsoft SDK程序集都使用WCF for SOAP端点,这在.net core中不受支持。因此,我不得不使用REST端点。我只需要基本的积垢操作 我尝试使用uncase-OData-Connectedservice()生成了一些代码。然而,所有的例子都只展示了如何添加服务,但还没有找到任何关于如何使用它的文档?
谢谢我已使用Uncase OData Connectedservice使其正常工作 我不得不用“System.Threading.Tasks.Task”重命名有问题的“Task” 与Async进行了斗争,但取得了如下进展:
public static async Task<IEnumerable<Account>> ExecuteCustomersQueryAsync()
{
OrgContext crm = new OrgContext(new Uri("http://<Server>/<Org>/XRMServices/2011/OrganizationData.svc/"));
crm.Credentials = new NetworkCredential("Username", "Password", "Domain");
DataServiceQuery<Account> query = crm.AccountSet
.AddQueryOption("$filter", "new_Class/Value eq 100000000");
try
{
(ODataStandartResponse, IEnumerable<Account>) rez = await query.ExecuteAsync();
return rez.Item2;
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException(
"An error occurred during query execution.", ex);
}
}
公共静态异步任务ExecuteCustomerQueryAsync()
{
OrgContext crm=新的OrgContext(新Uri(“http:////XRMServices/2011/OrganizationData.svc/"));
crm.Credentials=新的网络凭据(“用户名”、“密码”、“域”);
DataServiceQuery查询=crm.AccountSet
.AddQueryOption(“$filter”,“新类/值eq 100000000”);
尝试
{
(ODataStandartResponse,IEnumerable)rez=wait query.ExecuteAsync();
返回rez.Item2;
}
捕获(DataServiceQueryException ex)
{
抛出新的ApplicationException(
“查询执行期间发生错误。”,例如);
}
}
然后打电话:
IEnumerable<Account> container = await ExecuteCustomersQueryAsync();
try
{
foreach (Account cust in container)
{
Console.WriteLine("Customer Name: {0}, Acc No.: {1}", cust.Name, cust.AccountNumber);
}
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException("An error occurred during query execution.", ex);
}
IEnumerable container=await ExecuteCustomerQueryAsync();
尝试
{
foreach(容器中的客户帐户)
{
Console.WriteLine(“客户名称:{0},账号:{1}”,客户名称,客户账号);
}
}
捕获(DataServiceQueryException ex)
{
抛出新的ApplicationException(“查询执行期间发生错误。”,ex);
}
这是在以netcoreapp3.0为目标的控制台应用程序上测试的,因此应该可以在Blazor应用程序上使用。如果有任何问题,我们将在此处答复
希望它能帮助其他想做同样或类似事情的人