当前位置: 首页>>代码示例>>C#>>正文


C# MongoCollection.IsCapped方法代码示例

本文整理汇总了C#中MongoCollection.IsCapped方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.IsCapped方法的具体用法?C# MongoCollection.IsCapped怎么用?C# MongoCollection.IsCapped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCollection的用法示例。


在下文中一共展示了MongoCollection.IsCapped方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PasteValue

 /// <summary>
 /// </summary>
 /// <param name="elementPath"></param>
 /// <param name="currentDocument"></param>
 /// <param name="currentCollection"></param>
 public static void PasteValue(string elementPath, BsonDocument currentDocument,
     MongoCollection currentCollection)
 {
     var baseDoc = currentDocument;
     var t = GetLastParentDocument(baseDoc, elementPath, true);
     if (t.IsBsonArray)
     {
         t.AsBsonArray.Insert(t.AsBsonArray.Count, (BsonValue) ClipElement);
     }
     if (!currentCollection.IsCapped())
     {
         currentCollection.Save(baseDoc);
     }
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:19,代码来源:ElementHelper.cs

示例2: PasteElement

        //http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-UsageandRestrictions
        //Usage and Restrictions Of capped collection.
        //You may insert new documents in the capped collection.
        //You may update the existing documents in the collection. However, the documents must not grow in size. If they do, the update will fail. Note if you are performing updates, you will likely want to declare an appropriate index (given there is no _id index for capped collections by default).
        //The database does not allow deleting documents from a capped collection. Use the drop() method to remove all rows from the collection. (After the drop you must explicitly recreate the collection.)
        //Capped collection are not shard-able.

        /// <summary>
        ///     Paste
        /// </summary>
        /// <param name="elementPath"></param>
        /// <param name="currentDocument"></param>
        /// <param name="currentCollection"></param>
        public static string PasteElement(string elementPath, BsonDocument currentDocument,
            MongoCollection currentCollection)
        {
            var baseDoc = currentDocument;
            var t = GetLastParentDocument(baseDoc, elementPath, true);
            if (t.IsBsonDocument)
            {
                try
                {
                    t.AsBsonDocument.InsertAt(t.AsBsonDocument.ElementCount, (BsonElement) ClipElement);
                }
                catch (InvalidOperationException ex)
                {
                    return ex.Message;
                }
            }
            if (!currentCollection.IsCapped())
            {
                currentCollection.Save(baseDoc);
            }
            return string.Empty;
        }
开发者ID:jango2015,项目名称:MongoCola,代码行数:35,代码来源:ElementHelper.cs

示例3: ModifyElement

 /// <summary>
 /// Modify Element
 /// </summary>
 /// <param name="elementPath"></param>
 /// <param name="newValue"></param>
 /// <param name="el"></param>
 /// <param name="currentDocument"></param>
 /// <param name="currentCollection"></param>
 public static void ModifyElement(string elementPath, BsonValue newValue, BsonElement el,
     BsonDocument currentDocument, MongoCollection currentCollection)
 {
     var baseDoc = currentDocument;
     var t = GetLastParentDocument(baseDoc, elementPath, false);
     if (t.IsBsonDocument)
     {
         t.AsBsonDocument.SetElement(new BsonElement(el.Name, newValue));
     }
     if (!currentCollection.IsCapped())
     {
         currentCollection.Save(baseDoc);
     }
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:22,代码来源:ElementHelper.cs

示例4: ModifyArrayValue

 /// <summary>
 /// Modify A Value of Array
 /// </summary>
 /// <param name="elementPath"></param>
 /// <param name="newValue"></param>
 /// <param name="valueIndex"></param>
 /// <param name="currentDocument"></param>
 /// <param name="currentCollection"></param>
 public static void ModifyArrayValue(string elementPath, BsonValue newValue, int valueIndex,
     BsonDocument currentDocument, MongoCollection currentCollection)
 {
     var baseDoc = currentDocument;
     var t = GetLastParentDocument(baseDoc, elementPath, false);
     if (t.IsBsonArray)
     {
         t.AsBsonArray[valueIndex] = newValue;
     }
     if (!currentCollection.IsCapped())
     {
         currentCollection.Save(baseDoc);
     }
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:22,代码来源:ElementHelper.cs

示例5: DropArrayValue

 /// <summary>
 /// Drop A Value of Array
 /// </summary>
 /// <param name="elementPath"></param>
 /// <param name="valueIndex"></param>
 /// <param name="currentDocument"></param>
 /// <param name="currentCollection"></param>
 public static void DropArrayValue(string elementPath, int valueIndex, BsonDocument currentDocument,
     MongoCollection currentCollection)
 {
     var baseDoc = currentDocument;
     var t = GetLastParentDocument(baseDoc, elementPath, false);
     if (t.IsBsonArray)
     {
         t.AsBsonArray.RemoveAt(valueIndex);
     }
     if (!currentCollection.IsCapped())
     {
         currentCollection.Save(baseDoc);
     }
 }
开发者ID:jango2015,项目名称:MongoCola,代码行数:21,代码来源:ElementHelper.cs


注:本文中的MongoCollection.IsCapped方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。