예제 #1
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));
            }
        }
예제 #2
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 }));
            }
        }
예제 #3
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);
            }
        }