In a hierarchical data model i have Parent and Child. Parent has Fields[] and each child will also have the same "Count" of fields.. we'll call them ChildField[]
public class Parent : ActiveRecordBase<Parent>
{
[HasMany]
IList<Field> Fields {get; set;}
[HasMany]
IList<Child> Children {get; set;}
}
public class Child : ActiveRecordBase<Child>
{
[HasMany]
IList<ChildField> ChildFields {get; set;}
}
Now when you don't have any Fields inside Parent... but i have say 500 Child objects in its collection I sure dont want 500 selects (total) where each child tries to load its childField collection.
I suppose I can maybe do Lazy but at the same time.. when there are childFields I don't want it lazy and eager is going to be more performant isn't it?
ActiveRecordMediator might allow me to go something like
public void FetchByChild(Child child){
child.Parent.Fields.Count > 0
//Do the fetch
else
//return;
}
Does the mediator serve the purpose to "skip" db calls when additional knowledge of the "calling-context" is provided?