Support for loading of LazyLoaded properties via explicit join.

--HG--
extra : source : 1b7c96cb2a644ae17603c9d72ec09d94bc877bf1
pull/2/head
Taloth Saldono 11 years ago committed by Mark McDowall
parent 4515c1d155
commit 935c26d03e

@ -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);

@ -551,6 +551,17 @@ namespace Marr.Data.QGen
return Join(joinType, rightMember, filterExpression);
}
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, LazyLoaded<TRight>>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression)
{
_isJoin = true;
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
var relationship = EntGraph.Relationships.Single(v => v.Member == rightMember);
EntGraph.AddLazyRelationship(relationship);
return Join(joinType, rightMember, filterExpression);
}
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression)
{
_isJoin = true;

Loading…
Cancel
Save