This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
Linked Entity Query with a mixture of null and not null values returns wrong value #324
Comments
We have stumbled upon the same issue. Here is another test to reproduce it: [TestMethod]
public void Attributes_Dont_Bleed_Into_Other_Records_When_Joining()
{
var organizationService = new FakeXrmEasy.XrmFakedContext().GetOrganizationService();
var mainId = organizationService.Create(new Entity("main"));
//NOTE: The order of creation of the linked entities is important.
//Linked entity with attribute set to a value
organizationService.Create(new Entity("linked")
{
Attributes = new AttributeCollection {{"mainid", mainId}, {"attribute", "Data"}}
});
//Linked entity with attribute set to null
organizationService.Create(new Entity("linked")
{
Attributes = new AttributeCollection {{"mainid", mainId}, {"attribute", null}}
});
//Linked entity with attribute not set at all
organizationService.Create(new Entity("linked")
{
Attributes = new AttributeCollection { { "mainid", mainId } }
});
var queryExpression = new QueryExpression("main")
{
ColumnSet = new ColumnSet(true),
LinkEntities =
{
new LinkEntity("main", "linked", "mainid", "mainid", JoinOperator.Inner)
{
EntityAlias = "linked",
Columns = new ColumnSet(true)
}
}
};
//Should return all three linked records
var result = organizationService.RetrieveMultiple(queryExpression);
//Get attribute values of all linked entities
var attributeValues = result.Entities
.Select(e => e.Attributes.TryGetValue("linked.attribute", out var value) ? (value as AliasedValue)?.Value : null)
.ToList();
//Should get 1x Data and 2x null
attributeValues.Should().BeEquivalentTo(new object[] {"Data", null, null});
//Actual values: "Data", "Data", "Data"
} The problem appears to be in the method JoinAttributes. The "main" e entity gets re-used for every linked entity. Attributes from previous linked entities are not overwritten when they are null. |
BetimBeja
added a commit
to BetimBeja/fake-xrm-easy-v1
that referenced
this issue
Nov 4, 2018
note. fixed an error on the proposed test case too.
Merged
jordimontana82
added a commit
that referenced
this issue
Nov 5, 2018
mtone
pushed a commit
to mtone/fake-xrm-easy
that referenced
this issue
Jun 4, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have a query that returns columns from a linked entity. When the value of one of the fields of the linked entity is null, it being returned as the value of the previous entity when it should be being returned as null.
e.g.
I have forked the repo and added a unit test - see this commit:
daveb84@b17605d
Full test code:
The text was updated successfully, but these errors were encountered: