我目前正在尝试检索分配给特定安全角色或分配给具有安全角色的团队的所有系统用户。在构建查询时,似乎只在以and
这种方式编写查询时按条件过滤它们:
QueryExpression RolesQuery = new QueryExpression
{
EntityName = "systemuser",
ColumnSet = new ColumnSet("systemuserid"),
Distinct = true,
Criteria =
{
Filters =
{
new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("isdisabled", ConditionOperator.Equal, "0")
}
}
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = "systemuser",
LinkToEntityName = "systemuserroles",
LinkFromAttributeName = "systemuserid",
LinkToAttributeName = "systemuserid",
LinkCriteria =
{
Filters =
{
new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("roleid", ConditionOperator.Equal, "00000000-0000-0000-0000-000000000000")
}
}
}
}
},
new LinkEntity
{
LinkFromEntityName = "systemuser",
LinkToEntityName = "teammembership",
LinkFromAttributeName = "systemuserid",
LinkToAttributeName = "systemuserid",
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = "teammembership",
LinkToEntityName = "team",
LinkFromAttributeName = "teamid",
LinkToAttributeName = "teamid",
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = "team",
LinkToEntityName = "teamroles",
LinkFromAttributeName = "teamid",
LinkToAttributeName = "teamid",
LinkCriteria =
{
Filters =
{
new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("roleid", ConditionOperator.Equal, "00000000-0000-0000-0000-000000000000")
}
}
}
}
}
}
}
}
}
}
};
or
我的问题:有没有办法对两个链接实体应用过滤器?
我找到了一种解决方法,使用两个 fetch 表达式查询,然后合并两个结果并进行不同的计数,但我只是好奇查询表达式中是否有一种方法可以在一个查询中执行此操作。