protected void HandleValueHolderContainer(IValueHolderContainer vhc, RelationMember[] relationMembers, IObjRef[][] relations) { ICacheHelper cacheHelper = this.CacheHelper; ICacheIntern parent = this.Parent; IProxyHelper proxyHelper = this.ProxyHelper; for (int relationIndex = relationMembers.Length; relationIndex-- > 0;) { RelationMember relationMember = relationMembers[relationIndex]; IObjRef[] relationsOfMember = relations[relationIndex]; if (!CascadeLoadMode.EAGER.Equals(relationMember.CascadeLoadMode)) { if (ValueHolderState.INIT != vhc.Get__State(relationIndex)) { // Update ObjRef information within the entity and do nothing else vhc.Set__ObjRefs(relationIndex, relationsOfMember); continue; } } // We can safely access to relation if we want to if (relationsOfMember == null) { // Reset value holder state because we do not know the content currently vhc.Set__Uninitialized(relationIndex, null); continue; } Object relationValue = relationMember.GetValue(vhc); if (relationsOfMember.Length == 0) { if (!relationMember.IsToMany) { if (relationValue != null) { // Relation has to be flushed relationMember.SetValue(vhc, null); } } else { if (relationValue != null) { // Reuse existing collection ListUtil.ClearList(relationValue); } else { // We have to create a new empty collection relationValue = cacheHelper.CreateInstanceOfTargetExpectedType(relationMember.RealType, relationMember.ElementType); relationMember.SetValue(vhc, relationValue); } } continue; } // So we know the new content (which is not empty) and we know that the current content is already initialized // Now we have to refresh the current content eagerly // load entities as if we were an "eager valueholder" here IList <Object> potentialNewItems = parent.GetObjects(new List <IObjRef>(relationsOfMember), this, CacheDirective.None); if (OverwriteToManyRelations) { Object newRelationValue = cacheHelper.ConvertResultListToExpectedType(potentialNewItems, relationMember.RealType, relationMember.ElementType); // Set new to-many-relation, even if there has not changed anything in its item content relationMember.SetValue(vhc, newRelationValue); continue; } IList <Object> relationItems = ListUtil.AnyToList(relationValue); bool diff = (relationItems.Count != potentialNewItems.Count); if (!diff) { for (int b = potentialNewItems.Count; b-- > 0;) { if (!Object.ReferenceEquals(potentialNewItems[b], relationItems[b])) { diff = true; break; } } } if (!diff) { // Nothing to do continue; } if (relationValue != null && relationMember.IsToMany) { // Reuse existing collection ListUtil.ClearAndFillList(relationValue, relationItems); } else { // We have to create a new empty collection or replace the to-one value Object newRelationValue = cacheHelper.ConvertResultListToExpectedType(potentialNewItems, relationMember.RealType, relationMember.ElementType); relationMember.SetValue(vhc, newRelationValue); } } }