Insert() private method

private Insert ( object gmo ) : void
gmo object
return void
Beispiel #1
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);
         }
     }
 }
Beispiel #2
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);
         }
     }
 }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try {
                MongoClient   mc = new MongoClient("mongodb://*****:*****@ds153123.mlab.com:53123/store_games");
                MongoServer   ms = mc.GetServer();
                MongoDatabase db = ms.GetDatabase("store_games");
                ms.Connect(); // creo q este no hace falta ahorita veo

                var persona = new Persona()
                {
                    Cedula = textBox1.Text, Name = textBox2.Text
                };
                this.id = persona.Id;
                MongoCollection colleccion = db.GetCollection <Persona>("persona");
                colleccion.Insert(persona);
                MessageBox.Show("Persona guardada");
            }catch (Exception error) {
                MessageBox.Show("ERROR " + error);
            }
            textBox1.Text = "";
            textBox2.Text = "";
        }
Beispiel #4
0
 /// <summary>
 ///   Inserts the specified doc.
 /// </summary>
 /// <param name = "document">The document.</param>
 public void Insert(Document document)
 {
     _collection.Insert(document);
 }