Skip to content

Commit 487538b

Browse files
author
Bart Koelman
authored
Fixes error when using EagerLoad on a relationship (#1000)
1 parent a93ea81 commit 487538b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ private ICollection<PropertySelector> ToPropertySelectors(IDictionary<ResourceFi
133133
foreach (EagerLoadAttribute eagerLoad in resourceContext.EagerLoads)
134134
{
135135
var propertySelector = new PropertySelector(eagerLoad.Property);
136+
137+
// When an entity navigation property is decorated with both EagerLoadAttribute and RelationshipAttribute,
138+
// it may already exist with a sub-layer. So do not overwrite in that case.
139+
if (!propertySelectors.ContainsKey(propertySelector.Property))
140+
{
141+
propertySelectors[propertySelector.Property] = propertySelector;
142+
}
143+
136144
propertySelectors[propertySelector.Property] = propertySelector;
137145
}
138146

0 commit comments

Comments
 (0)