@@ -321,9 +321,7 @@ public virtual IQueryable<TEntity> Include(IQueryable<TEntity> entities, string
321
321
entity = _jsonApiContext . ContextGraph . GetContextEntity ( relationship . Type ) ;
322
322
}
323
323
324
- IQueryable < TEntity > included = entities . Include ( internalRelationshipPath ) ;
325
- AttachHasManyThrough ( relationshipChain , included ) ;
326
- return included ;
324
+ return entities . Include ( internalRelationshipPath ) ;
327
325
}
328
326
329
327
/// <inheritdoc />
@@ -370,29 +368,5 @@ public async Task<IReadOnlyList<TEntity>> ToListAsync(IQueryable<TEntity> entiti
370
368
? await entities . ToListAsync ( )
371
369
: entities . ToList ( ) ;
372
370
}
373
-
374
- private void AttachHasManyThrough ( string [ ] relationshipChain , IQueryable < TEntity > included )
375
- {
376
- var hasManyThroughRelationships = _jsonApiContext . RequestEntity . Relationships . OfType < HasManyThroughAttribute > ( ) ;
377
- foreach ( var hasManyThroughRelation in _jsonApiContext . RequestEntity . Relationships . OfType < HasManyThroughAttribute > ( ) )
378
- {
379
- if ( relationshipChain . Contains ( hasManyThroughRelation . PublicRelationshipName ) )
380
- {
381
- Type rightInstancesListType = typeof ( List < > ) . MakeGenericType ( hasManyThroughRelation . Type ) ;
382
- PropertyInfo rightPropertyOnLeft = _jsonApiContext . RequestEntity . EntityType . GetProperty ( hasManyThroughRelation . InternalRelationshipName ) ;
383
- foreach ( var leftInstance in included )
384
- {
385
- var rightInstancesList = ( IList ) Activator . CreateInstance ( rightInstancesListType ) ;
386
- var throughInstances = ( IList ) hasManyThroughRelation . ThroughProperty . GetValue ( leftInstance ) ;
387
- foreach ( var ti in throughInstances )
388
- {
389
- var rightInstance = hasManyThroughRelation . RightProperty . GetValue ( ti ) ;
390
- rightInstancesList . Add ( rightInstance ) ;
391
- }
392
- rightPropertyOnLeft . SetValue ( leftInstance , rightInstancesList ) ;
393
- }
394
- }
395
- }
396
- }
397
371
}
398
372
}
0 commit comments