Subversion Repositories blog-sources

Rev

Rev 8 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8 jlesech 1
using System;
2
 
9 jlesech 3
using MongoDB.Bson.Serialization;
8 jlesech 4
using MongoDB.Driver;
5
 
6
namespace Race
7
{
8
	class MainClass
9
	{
10
		public static void Main (string[] args)
11
		{
9 jlesech 12
			BsonClassMap.RegisterClassMap<Participant>
13
			(
14
				cm =>
15
				{
16
					cm.AutoMap();
17
					cm.GetMemberMap(c => c.Email).SetIgnoreIfNull(true);
18
				}
19
			);
20
 
8 jlesech 21
			// Get a Reference to the Client Object.
22
			string connectionString = "mongodb://localhost";
23
			MongoClient client = new MongoClient(connectionString);
24
 
25
			// Get a Reference to a Server Object.
26
			MongoServer server = client.GetServer();
27
 
28
			// Get a Reference to a Database Object.
29
			MongoDatabase database = server.GetDatabase("Race");
30
 
31
			// Get a Reference to a Collection Object.
32
			MongoCollection collection = database.GetCollection<Participant>("Participants");
33
 
34
			// Insert a Document.
35
			Participant participant = new Participant("Jean-Claude", "Duss", 1952);
36
			collection.Insert(participant);
37
		}
38
	}
39
}