public void ApplyTake(Expression argument)
        {
            if (this.Take != null)
            {
                throw new NotSupportedException("TODO: LOC: Cannot Apply Take twice.");
            }
            int num = ReduceToConstantVisitor.Reduce <int>(argument);

            if (num < 0)
            {
                throw new ArgumentException("TODO: LOC: 'Take' argument must be non-negative integer.");
            }
            this.Take = new int?(num);
        }
Ejemplo n.º 2
0
            private bool ProduceStringComparisonFilter(BinaryExpression node)
            {
                if (!node.Left.IsMethodCall(StringMethods.Compare))
                {
                    return(false);
                }
                MethodCallExpression methodCallExpression = (MethodCallExpression)node.Left;
                int num = ReduceToConstantVisitor.Reduce <int>(node.Right);

                if (num != 0)
                {
                    throw new UnsupportedExpressionException(Strings.StringCompareMustCompareToZero);
                }
                this.filter = new ComparisonFilter(node.NodeType.ToComparisonOperator(), this.GetPropertyDefinition(methodCallExpression.Arguments[0]), this.GetPropertyValue(methodCallExpression.Arguments[1]));
                return(true);
            }
Ejemplo n.º 3
0
            private bool ProduceConstantValue(Expression node)
            {
                bool result;

                try
                {
                    this.propertyValue    = ReduceToConstantVisitor.Reduce <object>(node);
                    this.hasPropertyValue = true;
                    result = true;
                }
                catch (NotSupportedException)
                {
                    result = false;
                }
                return(result);
            }
        public void ApplySkip(Expression argument)
        {
            if (this.Skip != null)
            {
                throw new NotSupportedException("TODO: LOC: Cannot Apply Skip twice.");
            }
            if (this.Take != null)
            {
                throw new NotSupportedException("TODO: LOC: Skip needs to be applied before Top is applied.");
            }
            int num = ReduceToConstantVisitor.Reduce <int>(argument);

            if (num < 0)
            {
                throw new ArgumentException("TODO: LOC: 'Skip' argument must be non-negative integer.");
            }
            this.Skip = new int?(num);
        }
Ejemplo n.º 5
0
        public static bool IsWhereIdEqualsKey <TKey>(this Expression expression, out TKey key)
        {
            key = default(TKey);
            LambdaExpression lambdaExpression = expression.FindLambdaExpression();

            if (lambdaExpression != null)
            {
                BinaryExpression binaryExpression = lambdaExpression.Body as BinaryExpression;
                if (binaryExpression != null && binaryExpression.NodeType == ExpressionType.Equal && binaryExpression.Left.Type == typeof(TKey) && binaryExpression.Right.Type == typeof(TKey) && binaryExpression.Left is MemberExpression && ReduceToConstantVisitor.CanReduce(binaryExpression.Right))
                {
                    MemberExpression memberExpression = (MemberExpression)binaryExpression.Left;
                    MemberInfo       member           = memberExpression.Member;
                    if (memberExpression.Expression == lambdaExpression.Parameters[0] && member.MemberType == MemberTypes.Property && member.Name == "Id")
                    {
                        key = ReduceToConstantVisitor.Reduce <TKey>(binaryExpression.Right);
                        return(true);
                    }
                }
            }
            return(false);
        }