gpt4 book ai didi

c# - 如何在 Dynamics 365 SDK 中检索没有 Guid 的实体?

转载 作者:太空宇宙 更新时间:2023-11-03 17:48:14 26 4
gpt4 key购买 nike

好吧,我有这个命令:IOrganizationService.Retrieve(String entityName, Guid ID, ColumnSet columnSet)引用:IOrganizationService

我尝试了 SDK 代码示例,但在创建记录时使用 Guid 获取信息,如下所示:Guid _accountId = orgService.Create(account);

我想使用帐户(实体)的名称获取此 Guid,我该怎么做?

最佳答案

您必须使用RetrieveMultiple 方法和QueryExpression 来实现它。例如下面的MSDN code example self 解释以获取与 lastname = “Brown”

的联系人
//  Query using ConditionExpression and FilterExpression
ConditionExpression condition1 = new ConditionExpression();
condition1.AttributeName = "lastname";
condition1.Operator = ConditionOperator.Equal;
condition1.Values.Add("Brown");

FilterExpression filter1 = new FilterExpression();
filter1.Conditions.Add(condition1);

QueryExpression query = new QueryExpression("contact");
query.ColumnSet.AddColumns("firstname", "lastname");
query.Criteria.AddFilter(filter1);

EntityCollection result1 = _serviceProxy.RetrieveMultiple(query);
Console.WriteLine();Console.WriteLine("Query using Query Expression with ConditionExpression and FilterExpression");
Console.WriteLine("---------------------------------------");
foreach (var a in result1.Entities)
{
Console.WriteLine("Name: " + a.Attributes["firstname"] + " " + a.Attributes["lastname"]);
}

Query expressions are used in methods that retrieve more than one record, such as the IOrganizationService.RetrieveMultiple method, in messages that perform an operation on a result set specified by a query expression, such as BulkDeleteRequest and when the ID for a specific record is not known.

Reference

关于c# - 如何在 Dynamics 365 SDK 中检索没有 Guid 的实体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51352710/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com