示例#1
0
 protected override Expression VisitMethodCall(MethodCallExpression node)
 {
     if (node.Method.IsEntitySetMethod())
     {
         var entType = node.Type.GetGenericArguments()[0];
         return(ExpressionMaker.MakeEntitySetConstant(entType));
     }
     if (node.Method.DeclaringType == typeof(EntityQueryExtensions) && node.Method.Name == nameof(EntityQueryExtensions.Include))
     {
         return(Visit(node.Arguments[0])); //Include lambda was already added to Info.Includes by analyzer
     }
     return(base.VisitMethodCall(node));
 }
示例#2
0
        // Setup methods

        private static void Setup_SelectByKey(SpecialLinqCommand command)
        {
            var key      = command.Key;
            var lockType = command.LockType;
            var orderBy  = command.OrderBy;

            var entType = key.Entity.EntityType;
            var prms    = key.ExpandedKeyMembers.Select(m => Expression.Parameter(m.Member.DataType, "@" + m.Member.MemberName)).ToArray();
            var pred    = ExpressionMaker.MakeKeyPredicate(key, prms);
            var entSet  = (lockType == LockType.None) ? key.Entity.EntitySetConstant
                                               : ExpressionMaker.MakeEntitySetConstant(entType, lockType);
            var entSetFiltered = ExpressionMaker.MakeCallWhere(entSet, pred);
            var entSetOrdered  = ExpressionMaker.AddOrderBy(entSetFiltered, command.OrderBy);
            var lambdaExpr     = Expression.Lambda(entSetOrdered, prms);

            command.Lambda = lambdaExpr;
        }