Ejemplo n.º 1
0
        public void AssociateWith <TEntity>(Expression <Func <TEntity, IEnumerable> > memberQuery) where TEntity : IEntity
        {
            var rootMember = RootMemberFinder.Find(memberQuery, memberQuery.Parameters[0]);

            if (rootMember != memberQuery.Body)
            {
                var memberParam = Expression.Parameter(rootMember.Type, "root");
                var newBody     = DbExpressionReplacer.Replace(memberQuery.Body, rootMember, memberParam);
                AddOperation(rootMember.Member, Expression.Lambda(newBody, memberParam));
            }
        }
Ejemplo n.º 2
0
        public void IncludeWith(LambdaExpression fnMember, bool deferLoad)
        {
            var rootMember = RootMemberFinder.Find(fnMember, fnMember.Parameters[0]);

            if (rootMember == null)
            {
                throw new InvalidOperationException("Subquery does not originate with a member access");
            }
            Include(rootMember.Member, deferLoad);
            if (rootMember != fnMember.Body)
            {
                AssociateWith(fnMember);
            }
        }
Ejemplo n.º 3
0
        public void AssociateWith(LambdaExpression memberQuery)
        {
            var rootMember = RootMemberFinder.Find(memberQuery, memberQuery.Parameters[0]);

            if (rootMember == null)
            {
                throw new InvalidOperationException("Subquery does not originate with a member access");
            }
            if (rootMember != memberQuery.Body)
            {
                var memberParam = Expression.Parameter(rootMember.Type, "root");
                var newBody     = ExpressionReplacer.Replace(memberQuery.Body, rootMember, memberParam);
                this.AddOperation(rootMember.Member, Expression.Lambda(newBody, memberParam));
            }
        }
Ejemplo n.º 4
0
        public void AssociateWith(LambdaExpression memberQuery)
        {
            MemberExpression searchFor = RootMemberFinder.Find(memberQuery, memberQuery.Parameters[0]);

            if (searchFor == null)
            {
                throw new InvalidOperationException("Subquery does not originate with a member access");
            }
            if (searchFor != memberQuery.Body)
            {
                ParameterExpression replaceWith = Expression.Parameter(searchFor.Type, "root");
                Expression          body        = ExpressionReplacer.Replace(memberQuery.Body, searchFor, replaceWith);
                this.AddOperation(searchFor.Member, Expression.Lambda(body, new ParameterExpression[] { replaceWith }));
            }
        }