Ejemplo n.º 1
0
            protected override Expression VisitBinary(BinaryExpression binary)
            {
                if (_operators.ContainsKey(binary.NodeType))
                {
                    var fragment = _parent.buildSimpleWhereClause(_mapping, binary);
                    _register.Peek()(fragment);

                    return null;
                }

                if ((binary.NodeType == ExpressionType.AndAlso) || (binary.NodeType == ExpressionType.OrElse))
                {
                    var separator = binary.NodeType == ExpressionType.AndAlso
                        ? "and"
                        : "or";

                    var compound = new CompoundWhereFragment(separator);
                    _register.Peek()(compound);
                    _register.Push(child => compound.Add(child));

                    Visit(binary.Left);
                    Visit(binary.Right);

                    _register.Pop();

                    return null;
                }


                throw new NotSupportedException($"Marten does not support the BinaryExpression {binary} (yet).");
            }
Ejemplo n.º 2
0
            protected override Expression VisitBinary(BinaryExpression binary)
            {
                if (_operators.ContainsKey(binary.NodeType))
                {
                    var fragment = _parent.buildSimpleWhereClause(_mapping, binary);
                    _register.Peek()(fragment);

                    return(null);
                }

                if ((binary.NodeType == ExpressionType.AndAlso) || (binary.NodeType == ExpressionType.OrElse))
                {
                    var separator = binary.NodeType == ExpressionType.AndAlso
                        ? "and"
                        : "or";

                    var compound = new CompoundWhereFragment(separator);
                    _register.Peek()(compound);
                    _register.Push(child => compound.Add(child));

                    Visit(binary.Left);
                    Visit(binary.Right);

                    _register.Pop();

                    return(null);
                }

                throw new NotSupportedException($"Marten does not support the BinaryExpression {binary} (yet).");
            }
Ejemplo n.º 3
0
        protected override Expression VisitMember(MemberExpression expression)
        {
            if (expression.Type == typeof(bool))
            {
                var locator        = _mapping.JsonLocator(expression);
                var whereFragments = new List <IWhereFragment>
                {
                    new WhereFragment($"{locator} IS NULL"),
                    new WhereFragment($"{locator} != ?", true)
                };
                var @where = new CompoundWhereFragment("or", whereFragments.ToArray());
                _callback(@where);
            }

            return(base.VisitMember(expression));
        }