Ejemplo n.º 1
0
        //Detect and retrieve sub-query in local variable
        protected override Expression VisitMember(MemberExpression node)
        {
            IQueryable subQuery;

            if (EntityQueryUtil.CheckSubQueryInLocalVariable(node, out subQuery))
            {
                var newExpr = Visit(subQuery.Expression);
                return(newExpr);
            }
            return(base.VisitMember(node));
        }
Ejemplo n.º 2
0
 protected override Expression VisitMethodCall(MethodCallExpression node)
 {
     if (node.Method.ReturnsEntitySet())
     {
         var entType = node.Type.GetGenericArguments()[0];
         var entInfo = _model.GetEntityInfo(entType, true);
         _command.Info.Entities.Add(entInfo);
         return(EntityQueryUtil.CreateEntitySetConstant(entType));
     }
     if (node.Method.DeclaringType == typeof(EntityQueryExtensions) && node.Method.Name == "Include")
     {
         return(Visit(node.Arguments[0])); //Include lambda was already added to Info.Includes by analyzer
     }
     return(base.VisitMethodCall(node));
 }
Ejemplo n.º 3
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 (EntityQueryUtil.CheckSubQueryInLocalVariable(node, out subQuery))
            {
                AnalyzeNode(subQuery.Expression); // we need to visit it as well, to process sub-query nodes
                return(ValueKind.Db);
            }
            //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
            }
        }