mirror of
https://github.com/Radarr/Radarr
synced 2025-02-26 16:13:19 +00:00
Support for loading of LazyLoaded properties via explicit join.
--HG-- extra : source : 1b7c96cb2a644ae17603c9d72ec09d94bc877bf1
This commit is contained in:
parent
4515c1d155
commit
935c26d03e
2 changed files with 23 additions and 1 deletions
|
@ -160,6 +160,14 @@ public List<EntityGraph> Children
|
|||
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 @@ public void AddEntity(object entityInstance)
|
|||
}
|
||||
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 @@ public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression
|
|||
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…
Reference in a new issue