Пример #1
0
        public static void _updateEmployeeObject(MongoDatabase db)
        {
            if (db.CollectionExists("employee"))
            {
                MongoCollection <Employee> values = db.GetCollection <Employee>("employee");
                Employee emp = values.FindOne();
                emp.Name = "Emp1000";

                values.Save(emp);
            }
        }
Пример #2
0
 public static void _updateEmployee(MongoDatabase db)
 {
     if (db.CollectionExists("employee"))
     {
         MongoCollection <BsonDocument> values = db.GetCollection("employee");
         BsonDocument bs = values.FindOne();
         bs.Set("name", BsonValue.Create("Emp100"));
         bs.Set("email", BsonValue.Create("*****@*****.**"));
         values.Save(bs);
     }
 }
Пример #3
0
 public static void _getEmployeeObject(MongoDatabase db)
 {
     if (db.CollectionExists("employee"))
     {
         MongoCollection <Employee> values = db.GetCollection <Employee>("employee");
         Console.WriteLine("Values:");
         foreach (Employee item in values.FindAll())
         {
             Console.WriteLine("{0}:{1}:{2}:{3}", item.Id.ToString(),
                               item.Name.ToString(), item.Email.ToString(), item.Created.ToString());
         }
     }
 }
Пример #4
0
 public static void _getEmployee(MongoDatabase db)
 {
     if (db.CollectionExists("employee"))
     {
         MongoCollection <BsonDocument> values = db.GetCollection("employee");
         Console.WriteLine("In employee:");
         foreach (var item in values.FindAll())
         {
             foreach (var item2 in item.Names)
             {
                 BsonElement el = item.GetElement(item2);
                 Console.WriteLine("{0} : {1}", item2, el.Value);
             }
         }
     }
 }
Пример #5
0
 public static void _fillEmployee(MongoDatabase db)
 {
     if (db.CollectionExists("employee"))
     {
         MongoCollection <BsonDocument> values = db.GetCollection("employee");
         for (int i = 0; i < 5; i++)
         {
             BsonDocument b = new BsonDocument {
                 { "name", "Epm" + i },
                 { "email", string.Format("e{0}@mail.ru", i) },
                 { "created", DateTime.Now }
             };
             values.Insert(b);
         }
     }
 }
Пример #6
0
 public static void _fillEmployeeObject(MongoDatabase db)
 {
     if (db.CollectionExists("employee"))
     {
         MongoCollection <Employee> values = db.GetCollection <Employee>("employee");
         for (int i = 0; i < 5; i++)
         {
             Employee b = new Employee
             {
                 Id      = ObjectId.GenerateNewId(),
                 Name    = "Epm" + i * 10,
                 Email   = string.Format("e{0}@mail.ru", i * 10),
                 Created = DateTime.Now
             };
             values.Insert(b);
         }
     }
 }