Пример #1
0
 /// <summary>
 /// Adds or updates a document in the collection
 /// </summary>
 /// <param name="id">The id of the document</param>
 /// <param name="item">
 /// The object that is being stored in the collection
 /// </param>
 public void AddOrUpdate(Guid id, T item)
 {
     if (this.Format == StorageFormat.BSON)
     {
         var record = new BsonRecord
         {
             Id   = id,
             Data = Serializer.SerializeBson <T>(item)
         };
         provider.AddOrUpdateRecord(record, this.Name);
     }
     else
     {
         var record = new JsonRecord
         {
             Id   = id,
             Data = Serializer.SerializeJson <T>(item)
         };
         provider.AddOrUpdateRecord(record, this.Name);
     }
 }