Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 8 | jlesech | 1 | using System; |
| 2 | |||
| 3 | using MongoDB.Driver; |
||
| 4 | |||
| 5 | namespace Race |
||
| 6 | { |
||
| 7 | class MainClass |
||
| 8 | { |
||
| 9 | public static void Main (string[] args) |
||
| 10 | { |
||
| 11 | // Get a Reference to the Client Object. |
||
| 12 | string connectionString = "mongodb://localhost"; |
||
| 13 | MongoClient client = new MongoClient(connectionString); |
||
| 14 | |||
| 15 | // Get a Reference to a Server Object. |
||
| 16 | MongoServer server = client.GetServer(); |
||
| 17 | |||
| 18 | // Get a Reference to a Database Object. |
||
| 19 | MongoDatabase database = server.GetDatabase("Race"); |
||
| 20 | |||
| 21 | // Get a Reference to a Collection Object. |
||
| 22 | MongoCollection collection = database.GetCollection<Participant>("Participants"); |
||
| 23 | |||
| 24 | // Insert a Document. |
||
| 25 | Participant participant = new Participant("Jean-Claude", "Duss", 1952); |
||
| 26 | collection.Insert(participant); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | } |