Support for loading of LazyLoaded properties via explicit join.

--HG--
extra : source : 1b7c96cb2a644ae17603c9d72ec09d94bc877bf1
This commit is contained in:
Taloth Saldono
2014-02-09 20:02:49 +01:00
committed by Mark McDowall
parent 4515c1d155
commit 935c26d03e
2 changed files with 23 additions and 1 deletions

View File

@@ -160,6 +160,14 @@ namespace Marr.Data
get { return _children; }
}
/// <summary>
/// Adds an Child in the graph for LazyLoaded property.
/// </summary>
public void AddLazyRelationship(Relationship childRelationship)
{
_children.Add(new EntityGraph(childRelationship.RelationshipInfo.EntityType.GetGenericArguments()[0], this, childRelationship));
}
/// <summary>
/// Adds an entity to the appropriate place in the object graph.
/// </summary>
@@ -182,7 +190,10 @@ namespace Marr.Data
}
else // RelationTypes.One
{
_relationship.Setter(_parent._entity, entityInstance);
if (_relationship.IsLazyLoaded)
_relationship.Setter(_parent._entity, Activator.CreateInstance(_relationship.MemberType, entityInstance));
else
_relationship.Setter(_parent._entity, entityInstance);
}
EntityReference entityRef = new EntityReference(entityInstance);