@@ -257,20 +257,28 @@ private object GetTrackedRelationshipValue(RelationshipAttribute relationshipAtt
257
257
}
258
258
}
259
259
260
+ // helper method used in GetTrackedRelationshipValue. See comments there.
260
261
private IList GetTrackedManyRelationshipValue ( IEnumerable < IIdentifiable > relationshipValueList , RelationshipAttribute relationshipAttr , ref bool wasAlreadyAttached )
261
262
{
262
263
if ( relationshipValueList == null ) return null ;
263
264
bool _wasAlreadyAttached = false ;
265
+ Type entityType = null ;
264
266
var trackedPointerCollection = relationshipValueList . Select ( pointer =>
265
267
{
268
+ /// todo: we can't just use relationshipAttr.Type because
269
+ /// this will point to the Resource type in the case of entity resource
270
+ /// separation. We should consider to store entity type on
271
+ /// the relationship attribute too.
272
+ entityType = entityType ?? pointer . GetType ( ) ;
266
273
var tracked = AttachOrGetTracked ( pointer ) ;
267
274
if ( tracked != null ) _wasAlreadyAttached = true ;
268
- return Convert . ChangeType ( tracked ?? pointer , relationshipAttr . Type ) ;
269
- } ) . ToList ( ) . Cast ( relationshipAttr . Type ) ;
275
+ return Convert . ChangeType ( tracked ?? pointer , entityType ) ;
276
+ } ) . ToList ( ) . Cast ( entityType ) ;
270
277
if ( _wasAlreadyAttached ) wasAlreadyAttached = true ;
271
278
return ( IList ) trackedPointerCollection ;
272
279
}
273
280
281
+ // helper method used in GetTrackedRelationshipValue. See comments there.
274
282
private IIdentifiable GetTrackedHasOneRelationshipValue ( IIdentifiable relationshipValue , HasOneAttribute hasOneAttribute , ref bool wasAlreadyAttached )
275
283
{
276
284
0 commit comments