I've asked a similar question before here and the answer solved my problem. However, now I'm getting the same problem as before but the answer doesn't work anymore due to change in conditions.
Here's the query I'm running. I've checked that someField
is set to something (it's a look-up field referring to an other entity by a guid). I get no entries in result
(unless I switch the condition to "not equal"). That's probably due to the fact that the field isn't brought in.
When i breakpoint the execution and check Attributes
, I see 21 fields out of a total of 30 (some of them might be empty, sure, but this one, i.e. someField
, is not) but the one I'm interested in, isn't there!
QueryExpression query = new QueryExpression
{
EntityName = "entity",
ColumnSet = new ColumnSet{ AllColumns = true },
// Here I tried the code addition #1 below
Criteria =
{
Filters =
{
new FilterExpression
{
Conditions =
{
new ConditionExpression("someField", ConditionOperator.Equal, guid)
}
}
}
}
};
// Here I tried the code addition #2 below
EntityCollection result = Service.RetrieveMultiple(query);
What do I miss and how can I resolve it?
I tried using LinkEntities
as discussed in this blog but it didn't really work out. I'm not even sure if it was a meaningful approach. It looked as follows.
LinkEntities =
{
new LinkEntity
{
Columns = new ColumnSet { AllColumns = true },
LinkFromEntityName = "entity",
LinkFromAttributeName = "otherEntityId",
LinkToEntityName = "entity2",
LinkToAttributeName = "entity2Id"
}
},
I also tried to employ the solution suggested on MSDN. The same result.
request.LinkEntities.Add(
new LinkEntity(
"entity", "entity2", "otherEntityId", "entity2Id", JoinOperator.Inner));
request.LinkEntities[0].Columns.AddColumns("entity2Id");
request.LinkEntities[0].EntityAlias = "blobb";
Once again - the solution provided by @JamesWood isn't working anymore, since I've got the administrator access and the regarded field is not empty.