Skip to content

Commit 0ab51ef

Browse files
committed
fix(document-builder): unique inclusion of entity
ensures that an entity will only be added to the included references once
1 parent 47a73ac commit 0ab51ef

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/JsonApiDotNetCore/Builders/DocumentBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ private List<DocumentData> GetIncludedEntities(ContextEntity contextEntity, IIde
188188
private void AddIncludedEntity(List<DocumentData> entities, IIdentifiable entity)
189189
{
190190
var includedEntity = GetIncludedEntity(entity);
191-
if(includedEntity != null)
191+
192+
if(includedEntity != null && !entities.Any(doc => doc.Id == includedEntity.Id && doc.Type == includedEntity.Type))
192193
entities.Add(includedEntity);
193194
}
194195

0 commit comments

Comments
 (0)