Created
September 25, 2011 13:03
-
-
Save joelmartinez/1240580 to your computer and use it in GitHub Desktop.
Minimal C#/MongoDb HowTo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoServer server = MongoServer.Create("mongodb://TheUserName:ThePassword@The.Url.Com:12345/TheDatabaseId"); | |
MongoDatabase mongo = server.GetDatabase("<TheDatabaseId>"); | |
var employees = mongo.GetCollection<TheClass>("TheCollectionName"); | |
var cursor = employees.FindAllAs<TheClass>(); | |
var item = cursor.FirstOrDefault(); | |
.... | |
public class TheClass | |
{ | |
[BsonId] | |
public object _id { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment