Skip to content

Commit 57e07f9

Browse files
author
Bart Koelman
committed
Hooks fix
1 parent e523a3e commit 57e07f9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ private IResourceReadRepository<TResource, TId> GetRepository<TResource, TId>()
144144
return _genericProcessorFactory.Get<IResourceReadRepository<TResource, TId>>(typeof(IResourceReadRepository<,>), typeof(TResource), typeof(TId));
145145
}
146146

147-
148147
public Dictionary<RelationshipAttribute, IEnumerable> LoadImplicitlyAffected(
149148
Dictionary<RelationshipAttribute, IEnumerable> leftEntitiesByRelation,
150149
IEnumerable existingRightEntities = null)
@@ -159,17 +158,20 @@ public Dictionary<RelationshipAttribute, IEnumerable> LoadImplicitlyAffected(
159158

160159
foreach (IIdentifiable ip in includedLefts)
161160
{
162-
IList dbRightEntityList;
161+
IList dbRightEntityList = TypeHelper.CreateListFor(relationship.RightType);
163162
var relationshipValue = relationship.GetValue(ip);
164163
if (!(relationshipValue is IEnumerable))
165164
{
166-
dbRightEntityList = TypeHelper.CreateListFor(relationship.RightType);
167165
if (relationshipValue != null) dbRightEntityList.Add(relationshipValue);
168166
}
169167
else
170168
{
171-
dbRightEntityList = (IList)relationshipValue;
169+
foreach (var item in (IEnumerable) relationshipValue)
170+
{
171+
dbRightEntityList.Add(item);
172+
}
172173
}
174+
173175
var dbRightEntityListCast = dbRightEntityList.Cast<IIdentifiable>().ToList();
174176
if (existingRightEntities != null) dbRightEntityListCast = dbRightEntityListCast.Except(existingRightEntities.Cast<IIdentifiable>(), _comparer).ToList();
175177

0 commit comments

Comments
 (0)