我正在尝试使用查询表达式进行简单的内部连接。我试图用 QE 来隐藏这个查询,但我总是遇到同样的错误。我正在做这个量化宽松:
Entity Role = new Entity();
Role.LogicalName = "role";
Entity SystemUserRoles = new Entity();
SystemUserRoles.LogicalName = "systemuserroles";
QueryExpression query = new QueryExpression() {
Distinct = false, EntityName = Role.LogicalName, ColumnSet = new ColumnSet("name"),
LinkEntities = {
new LinkEntity {
JoinOperator = JoinOperator.Inner, LinkFromAttributeName = "roleid", LinkFromEntityName = Role.LogicalName, LinkToAttributeName = "roleid", LinkToEntityName = SystemUserRoles.LogicalName,
}
},
Criteria = {
Filters = {
new FilterExpression {
FilterOperator = LogicalOperator.And, Conditions = {
new ConditionExpression("systemuserid", ConditionOperator.Equal, "9b1bf31d-ac29-e211-9826-00155d0a0b0f"),
},
},
}
}
};
ret = _service.RetrieveMultiple(query);
得到这个:
SELECT b.Name
FROM Role b
INNER JOIN SystemUserRoles a
ON a.RoleId=b.RoleId
WHERE SystemUserId = '9b1bf31d-ac29-e211-9826-00155d0a0b0f'
但这告诉我实体角色不包含该字段SystemUserId
。任何的想法?