带有 PartyList 的 QueryExpression 中的错误
Error in QueryExpression with PartyList
我正在尝试检索其 "requiredattendees" 包含在帐户列表中的实体之一上的约会。 requiredattendees 有一种 PartyList。
我的查询看起来像:
var query = new QueryExpression("appointment")
{
ColumnSet = columnSet,
Criteria = new FilterExpression(LogicalOperator.Or)
};
并添加条件:
GetAccounts()
.Select(a => new ConditionExpression("requiredattendees", ConditionOperator.Contains, a.Id))
.ForEach(c => query.Criteria.AddCondition(c));
a.Id is the account guid.
我收到以下错误:
Cannot add attribute requiredattendees of type partylist in a condition
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral]]
此代码用于服务预约,但如果我没记错的话,预约也是一样的。希望这有帮助
QueryExpression qe = new QueryExpression
{
EntityName = "serviceappointment",
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "scheduledstart",
Operator = ConditionOperator.LessThan,
Values =
{
endTime
}
},
new ConditionExpression
{
AttributeName = "scheduledend",
Operator = ConditionOperator.GreaterThan,
Values =
{
startTime
}
}
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = "activitypointer",
LinkFromAttributeName = "activityid",
LinkToEntityName = "activityparty",
LinkToAttributeName = "activityid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "partyid",
Operator = ConditionOperator.Equal,
Values =
{
someEntity.id
}
}
}
}
}
}
};
QueryExpression query = new QueryExpression(LetterEntityAttributeNames.EntityName)
{
ColumnSet = new ColumnSet(new string[]
{
LetterEntityAttributeNames.SubjectFieldName,
LetterEntityAttributeNames.RegardingObjectId,
LetterEntityAttributeNames.ToFieldName
}),
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = LetterEntityAttributeNames.DirectChannelTypeFieldName,
Operator = ConditionOperator.Equal,
Values =
{
DirectChannelType
}
},
new ConditionExpression
{
AttributeName = LetterEntityAttributeNames.RegardingObjectId,
Operator = ConditionOperator.Equal,
Values =
{
RegardingId
}
}
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = ActivityPointerEntityAttributeNames.EntityName,
LinkFromAttributeName = ActivityPartyAttributeNames.ActivityId,
LinkToEntityName = ActivityPartyAttributeNames.EntityName,
LinkToAttributeName = CampaignActivityAttributeNames.Id,
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = ActivityPointerAttributeNames.PartyIdField,
Operator = ConditionOperator.Equal,
Values =
{
ToEntityGuid
}
}
}
}
}
}
};
我正在尝试检索其 "requiredattendees" 包含在帐户列表中的实体之一上的约会。 requiredattendees 有一种 PartyList。 我的查询看起来像:
var query = new QueryExpression("appointment")
{
ColumnSet = columnSet,
Criteria = new FilterExpression(LogicalOperator.Or)
};
并添加条件:
GetAccounts()
.Select(a => new ConditionExpression("requiredattendees", ConditionOperator.Contains, a.Id))
.ForEach(c => query.Criteria.AddCondition(c));
a.Id is the account guid.
我收到以下错误:
Cannot add attribute requiredattendees of type partylist in a condition
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral]]
此代码用于服务预约,但如果我没记错的话,预约也是一样的。希望这有帮助
QueryExpression qe = new QueryExpression
{
EntityName = "serviceappointment",
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "scheduledstart",
Operator = ConditionOperator.LessThan,
Values =
{
endTime
}
},
new ConditionExpression
{
AttributeName = "scheduledend",
Operator = ConditionOperator.GreaterThan,
Values =
{
startTime
}
}
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = "activitypointer",
LinkFromAttributeName = "activityid",
LinkToEntityName = "activityparty",
LinkToAttributeName = "activityid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "partyid",
Operator = ConditionOperator.Equal,
Values =
{
someEntity.id
}
}
}
}
}
}
};
QueryExpression query = new QueryExpression(LetterEntityAttributeNames.EntityName)
{
ColumnSet = new ColumnSet(new string[]
{
LetterEntityAttributeNames.SubjectFieldName,
LetterEntityAttributeNames.RegardingObjectId,
LetterEntityAttributeNames.ToFieldName
}),
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = LetterEntityAttributeNames.DirectChannelTypeFieldName,
Operator = ConditionOperator.Equal,
Values =
{
DirectChannelType
}
},
new ConditionExpression
{
AttributeName = LetterEntityAttributeNames.RegardingObjectId,
Operator = ConditionOperator.Equal,
Values =
{
RegardingId
}
}
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName = ActivityPointerEntityAttributeNames.EntityName,
LinkFromAttributeName = ActivityPartyAttributeNames.ActivityId,
LinkToEntityName = ActivityPartyAttributeNames.EntityName,
LinkToAttributeName = CampaignActivityAttributeNames.Id,
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = ActivityPointerAttributeNames.PartyIdField,
Operator = ConditionOperator.Equal,
Values =
{
ToEntityGuid
}
}
}
}
}
}
};