我在使用需要返回基于给定电子邮件地址的记录的 GUID 的方法时遇到问题。这就是我目前所拥有的:
ColumnSet columnSet = new ColumnSet();
columnSet.AddColumns(new[] { "leadid" });
var query = new QueryExpression
{
EntityName = "lead",
ColumnSet = columnSet
};
FilterExpression leadFilter = new FilterExpression();
leadFilter.AddCondition(new ConditionExpression
{
AttributeName = "emailaddress1",
Operator = ConditionOperator.Equal,
Values = new object[] { emailAddress }
});
query.Criteria = leadFilter;
BusinessEntityCollection result = crmService.RetrieveMultiple(query);
foreach (BusinessEntity record in result)
{
//Guid leadId = ?? Not sure how to extract it.
}
A)这似乎有点矫枉过正,因为我只需要一条记录(但不要认为我可以使用 Retrieve,因为我没有 id)。B)我如何在 foreach 中从上述内容中实际检索 GUID?
谢谢。