如何使用单个 QueryExpression 查询多个实体

发布于 2024-12-20 15:50:10 字数 801 浏览 0 评论 0原文

我正在尝试运行 microsoft Dynamics crm 4.0 查询。当我像之前所做的那样为“一个”特定实体生成查询表达式时,这会按预期工作。然而问题是我如何定义多个实体,以便我可以应用另一种方法中的逻辑?一个例子或插图会很有帮助。

所以我所拥有的是这种格式:

static BusinessEntityCollection GetData(CrmService service)
{
    cols = new ColumnSet();
    cols.Attributes = new string[] { "x", "y", "z"};

    FilterExpression filter = new FilterExpression();
    filter.FilterOperator = LogicalOperator.And;

    QueryExpression query = new QueryExpression();
    query.EntityName = EntityName.incident.ToString();

    // i am trying to add something like the below
    query.EntityName = EntityName.account.toString();

    query.ColumnSet = cols;
    query.Criteria = filter;

    return service.RetrieveMultiple(query);
}

我面临的限制是我只能查询一个实体,并且我需要一种解决方案或解决方法来访问和查询多个实体。非常感谢您的帮助。

I am trying to run a microsoft dynamics crm 4.0 query. This works as expected when I generate a QueryExpression for "ONE" specific entity as I had done before. The issue however is how do i define more than one entity so i can apply logic that i have in another method? An example or illistration would be helpful.

so what i have is in this format:

static BusinessEntityCollection GetData(CrmService service)
{
    cols = new ColumnSet();
    cols.Attributes = new string[] { "x", "y", "z"};

    FilterExpression filter = new FilterExpression();
    filter.FilterOperator = LogicalOperator.And;

    QueryExpression query = new QueryExpression();
    query.EntityName = EntityName.incident.ToString();

    // i am trying to add something like the below
    query.EntityName = EntityName.account.toString();

    query.ColumnSet = cols;
    query.Criteria = filter;

    return service.RetrieveMultiple(query);
}

The restriction I am facing is I can only query one entity and I need a solution or workaround to access and query multiple entities. Your help is much appreciated.

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

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

发布评论

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

评论(1

债姬 2024-12-27 15:50:11

简单的回答:你不能。您一次只能查询一个实体。

查询表达式用于单个对象搜索,例如,搜索符合特定搜索条件的所有帐户。

了解如何构建查询
您必须合并对您想要获取的实体的多个请求。

FetchXML 也存在同样的限制。它基本上是 QueryExpression。请参阅如何使用 FetchXML

Simple answer: you can't. You could only query one entity at one time.

A query expression is used for single-object searches, for example, to search for all accounts that match certain search criteria.

See how to build queries.
You have to combine multiple requests for the entities you would like to get.

The same restriction exists for FetchXML. It is basically the serialized form of a QueryExpression. See how to use FetchXML

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