Пример #1
0
        private void PutInnerPredicate(QueryDocument doc, string op, object value)
        {
            var name = this.FieldName;
            BsonDocument innerDoc;

            if (doc.Contains(name))
            {
                innerDoc = doc[name] as BsonDocument;
                if (innerDoc == null)
                {
                    throw new InvalidOperationException("Should have nothing or BsonDocument object");
                }
            }
            else
            {
                innerDoc = new BsonDocument();
                doc.Add(name, innerDoc);
            }

            innerDoc.Add(op, this.TypeProcessor.ToBsonValue(value));
        }
Пример #2
0
        void IPropertyPredicateOperator.PutInPredicate(QueryDocument doc, IEnumerable<object> collection)
        {
            var name = this.FieldName;
            if (doc.Contains(name))
            {
                throw new InvalidOperationException(
                    String.Format(
                        "this document should not contain {0} field.", name));
            }

            var array = new BsonArray();
            foreach (var item in collection)
            {
                var value = this.TypeProcessor.ToBsonValue(item);
                array.Add(value);
            }

            doc.Add(name, new BsonDocument().Add("$in", array));
        }
Пример #3
0
        void IPropertyPredicateOperator.PutRegexMatchPredicate(QueryDocument doc, string expression, string options)
        {
            var name = this.FieldName;
            if (doc.Contains(name))
            {
                throw new InvalidOperationException(
                    String.Format(
                        "this document should not contain {0} field.", name));
            }

            doc.Add(name, new BsonRegularExpression(expression, options));
        }
Пример #4
0
        void IPropertyPredicateOperator.PutEqualPredicate(QueryDocument doc, object value)
        {
            var name = this.FieldName;
            if (doc.Contains(name))
            {
                throw new InvalidOperationException(
                    String.Format(
                        "this document should not contain {0} field.", name));
            }

            doc.Add(name, this.TypeProcessor.ToBsonValue(value));
        }