如何使用单个 QueryExpression 查询多个实体
我正在尝试运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的回答:你不能。您一次只能查询一个实体。
了解如何构建查询。
您必须合并对您想要获取的实体的多个请求。
FetchXML 也存在同样的限制。它基本上是
QueryExpression
。请参阅如何使用 FetchXMLSimple answer: you can't. You could only query one entity at one time.
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