Пример #1
0
        public static UpdateDocument ToUpdateDocument(this TextContent content)
        {
            UpdateDocument doc = new UpdateDocument();

            foreach (var item in content)
            {
                doc[item.Key] = BsonHelper.Create(item.Value);
            }
            return(doc);
        }
Пример #2
0
 public static QueryComplete NEIgnoreCase(string fieldName, object value)
 {
     if (value is string)
     {
         return(QueryBuilder.Query.Not(fieldName).Matches(new BsonRegularExpression("^" + Regex.Escape(value.ToString()) + "$", "i")));
     }
     {
         return(QueryBuilder.Query.NE(fieldName, BsonHelper.Create(value)));
     }
 }
Пример #3
0
        public static UpdateDocument ToUpdateDocument(this TextContent textContent)
        {
            textContent = textContent.ConvertToUTCTime();
            UpdateDocument doc = new UpdateDocument();

            foreach (var item in textContent)
            {
                doc[item.Key] = BsonHelper.Create(item.Value);
                doc[GetCaseInsensitiveFieldName(item.Key)] = BsonHelper.Create(ToCaseInsensitiveValue(item.Value));
            }
            return(doc);
        }
Пример #4
0
        public static TextContent ToContent(this BsonDocument doc)
        {
            if (doc == null)
            {
                return(null);
            }
            TextContent content = new TextContent();

            foreach (var item in doc)
            {
                if (item.Name != "_id")
                {
                    content[item.Name] = BsonHelper.GetValue(doc[item.Name]);
                }
            }
            return(content);
        }
Пример #5
0
        public static TextContent ToContent(this BsonDocument doc)
        {
            if (doc == null)
            {
                return(null);
            }
            TextContent content = new TextContent();

            foreach (var item in doc)
            {
                if (item.Name != "_id" && !IsCaseInsensitiveFieldName(item.Name))
                {
                    content[item.Name] = BsonHelper.GetValue(doc[item.Name]);
                }
            }
            return(content.ConvertToLocalTime());
        }
Пример #6
0
 public static IMongoQuery ToQuery(this Category category)
 {
     return(Builders.Query.And(Builders.Query.EQ("CategoryFolder", BsonHelper.Create(category.CategoryFolder)),
                               Builders.Query.EQ("CategoryUUID", BsonHelper.Create(category.CategoryUUID)),
                               Builders.Query.EQ("ContentUUID", BsonHelper.Create(category.ContentUUID))));
 }
Пример #7
0
        public static IMongoQuery NEIgnoreCase(string fieldName, object value)
        {
            value = ModelExtensions.ToCaseInsensitiveValue(value);

            return(QueryBuilder.Query.NE(ModelExtensions.GetCaseInsensitiveFieldName(fieldName), BsonHelper.Create(value)));
        }