Subversion Repositories blog-sources

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

using System;

using MongoDB.Driver;

namespace Race
{
        class MainClass
        {
                public static void Main (string[] args)
                {
                        // Get a Reference to the Client Object.
                        string connectionString = "mongodb://localhost";
                        MongoClient client = new MongoClient(connectionString);

                        // Get a Reference to a Server Object.
                        MongoServer server = client.GetServer();

                        // Get a Reference to a Database Object.
                        MongoDatabase database = server.GetDatabase("Race");

                        // Get a Reference to a Collection Object.
                        MongoCollection collection = database.GetCollection<Participant>("Participants");

                        // Insert a Document.
                        Participant participant = new Participant("Jean-Claude", "Duss", 1952);
                        collection.Insert(participant);
                }
        }
}