Ejemplo n.º 1
0
 /// <summary>
 /// Adds a replacement document as the update modifier.
 /// </summary>
 /// <param name="nominalType">The nominal type of the replacement document</param>
 /// <param name="document">The document.</param>
 /// <returns>An UpdateWrapper.</returns>
 public static IMongoUpdate Replace(
     Type nominalType,
     object document
     )
 {
     return(UpdateWrapper.Create(nominalType, document));
 }
Ejemplo n.º 2
0
        public void TestSerializeUpdateWrapped()
        {
            var c = new C {
                X = 1
            };
            var w        = UpdateWrapper.Create(c);
            var json     = w.ToJson();
            var expected = "{ 'X' : 1 }".Replace("'", "\"");

            Assert.Equal(expected, json);
        }
Ejemplo n.º 3
0
        public void UpdateWrapperType()
        {
            var document = new BsonDocument
            {
                {
                    "$set", new BsonDocument
                    {
                        { "Age", 54 }
                    }
                }
            };
            var update = UpdateWrapper.Create(document);

            Console.WriteLine(update.ToBsonDocument());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a replacement document as the update modifier.
 /// </summary>
 /// <typeparam name="TNominalType">The nominal type of the replacement document</typeparam>
 /// <param name="document">The document.</param>
 /// <returns>An UpdateWrapper.</returns>
 public static IMongoUpdate Replace <TNominalType>(
     TNominalType document
     )
 {
     return(UpdateWrapper.Create <TNominalType>(document));
 }