Example #1
0
        private ValueKind AnalyzeMember(MemberExpression node)
        {
            // check if it is subquery stored in local variable; if yes, retrieve the value and convert to constant
            IQueryable subQuery;

            if (LinqExpressionHelper.CheckSubQueryInLocalVariable(node, out subQuery))
            {
                AnalyzeNode(subQuery.Expression); // we need to visit it as well, to process sub-query nodes
                return(ValueKind.Db);
            }

            if (node.Type.IsSubclassOf(typeof(LinqLiteralBase)))
            {
                return(ValueKind.Constant);
            }
            if (node.Type == typeof(SequenceDefinition))
            {
                return(ValueKind.Constant);
            }

            //regular member access node
            var exprValueKind = this.AnalyzeNode(node.Expression);

            AddCacheKey(node.Member.Name);
            if (node.Member.IsStaticMember())
            {
                return(ValueKind.Local);
            }
            else
            {
                return(exprValueKind); //same as mexp.Expression's valueKind
            }
        }
Example #2
0
        //Detect and retrieve sub-query in local variable
        protected override Expression VisitMember(MemberExpression node)
        {
            IQueryable subQuery;

            if (LinqExpressionHelper.CheckSubQueryInLocalVariable(node, out subQuery))
            {
                var newExpr = Visit(subQuery.Expression);
                return(newExpr);
            }
            return(base.VisitMember(node));
        }