使用 RetrieveMultipleRequest 检索相关实体

发布于 2024-10-16 23:02:06 字数 1083 浏览 0 评论 0原文

我有一个名为 Invoice 的实体和一个名为 InvoiceItem 的实体。

有一个名为 new_invoice_invoiceitem 的一对多关系。

InvoiceItem 中有一个名为 new_parent_invoice_invoiceitem 的 LookupAttribute。

我尝试使用以下代码检索与具有特定 ID 的发票相关的 InvoiceItems:

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;

代码运行没有错误,但 BusinessEntityCollection 始终为空,即使 Dynamics 中有记录。

知道我做错了什么吗?

谢谢,

大卫

I have an entity called Invoice and an entity called InvoiceItem.

There is a one to many relationship called new_invoice_invoiceitem.

There is a LookupAttribute in InvoiceItem called new_parent_invoice_invoiceitem.

I am trying to retrieve the InvoiceItems that are related to the Invoice with a particular ID using the following code:

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;

The code runs without errors but the BusinessEntityCollection is always empty even though there are records in Dynamics.

Any idea what I'm doing wrong?

Thanks,

David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

表情可笑 2024-10-23 23:02:06

尝试设置 request.ReturnDynamicEntities = true

Try setting request.ReturnDynamicEntities = true

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文