我有一个名为Invoice的实体和一个名为InvoiceItem的实体。
有一对多叫做new_invoice_invoiceitem的关系。
InvoiceItem中有一个名为new_parent_invoice_invoiceitem的LookupAttribute。
我正在尝试使用以下代码检索与特定ID的Invoice相关的InvoiceItem:
QueryExpression query = new QueryExpression();
query.EntityName = "new_invoiceitem";
query.ColumnSet = new AllColumns();
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "new_parent_invoice_invoiceitem";
condition.Values = new object [] { new Guid("fe1009cc-e034-49d5-bc59-ab4c3091a6f9") };
condition.Operator = ConditionOperator.Equal;
FilterExpression filter = new FilterExpression();
filter.AddCondition(condition);
query.Criteria = filter;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);
BusinessEntityCollection bec = response.BusinessEntityCollection;
代码运行没有错误,但即使Dynamics中有记录,BusinessEntityCollection也始终为空。
知道我做错了吗?
谢谢,
大卫
答案 0 :(得分:2)
尝试设置request.ReturnDynamicEntities = true