public CompareIndexExpression(PropertyPath path, CompareOperation compareOperation, object value)
 {
     _path = path;
     _compareOperation = compareOperation;
     _value = value;
 }
示例#2
0
 public OrderingExpression(PropertyPath path, Expression expression, OrderingDirection direction)
 {
     _path = path;
     _expression = expression;
     _direction = direction;
 }
        public void Property(MemberExpression expression)
        {
            if (_propertyPath == null)
                _propertyPath = new PropertyPath();

            _propertyPath.Add(expression);

            var previous = _expressions.Pop();
            var newExpression = Expression.Property(previous, (PropertyInfo) expression.Member);
            _expressions.Push(newExpression);
        }
        private bool TryBinaryAnalyzeCompare(CompareOperation operation, Expression right)
        {
            if (_propertyPath == null) return false;

            var path = _propertyPath;
            var pathString = _propertyPath.GetUniqueName();
            _propertyPath = null;

            if (_entityMap == null) return false;

            if (operation == CompareOperation.Equal
                && string.Equals(pathString, _entityMap.KeyName, StringComparison.InvariantCulture)) {
                _executor.EqualKey(((ConstantExpression) right).Value);
                return true;
            }

            var index = _entityMap.Indexes.FirstOrDefault(i => string.Equals(i.UniqueName, pathString, StringComparison.InvariantCulture));

            if (index == null) return false;

            _executor.Compare(path, operation, ((ConstantExpression)right).Value);
            return true;
        }
        public void OrderBy(OrderingDirection orderingDirection)
        {
            var orderByExpression = _expressions.Pop();

            if (_propertyPath == null)
                throw new ExpressionTreeParseException("Order by requires an entity property");

            var path = _propertyPath;

            _orderings.Add(new OrderingExpression(path, orderByExpression, orderingDirection));

            var pathString = _propertyPath.GetUniqueName();
            _propertyPath = null;

            if (_entityMap == null) return;

            var index = _entityMap.Indexes.FirstOrDefault(i => string.Equals(i.UniqueName, pathString, StringComparison.InvariantCulture));

            if (index == null) return;

            _executor.OrderBy(path, OrderingDirections.Get(orderingDirection));
        }
        public void Contains()
        {
            var property = (MemberExpression) _expressions.Pop();
            var constant = (ConstantExpression) _expressions.Pop();
            // property = _propertyPath.GetExpression(_parameters);
            _propertyPath = null;

            var containsMethod = constant.Type.GetMethod("Contains");
            var expression = Expression.Call(constant, containsMethod, property);
            _expressions.Push(expression);
        }
 public void OrderBy(PropertyPath path, OrderingDirection direction)
 {
     _orderings.Add(new EmbeddedIndexOrdering(path, direction));
 }
 public void Compare(PropertyPath path, CompareOperation compareOperation, object value)
 {
     _expressions.Push(new CompareIndexExpression(path, compareOperation, value));
 }
 public EmbeddedIndexOrdering(PropertyPath path, OrderingDirection direction)
 {
     _path = path;
     _direction = direction;
 }