Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Created April 22, 2013 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyond-code-github/5438273 to your computer and use it in GitHub Desktop.
Save beyond-code-github/5438273 to your computer and use it in GitHub Desktop.
Using the MongoDocument class
var mongoCollection = database.GetCollection<MongoDocument>("Dynamic");
mongoCollection.Insert(
new MongoDocument(
new BsonDocument {
{ "Name", "A test record" },
{ "Date", new DateTime(2013,01,01) },
{ "Age", 28 },
{ "Complete", false } }));
mongoCollection.Insert(
new MongoDocument(
new BsonDocument {
{ "Name", "Another test" },
{ "Date", new DateTime(2013,02,02) },
{ "Age", 36 },
{ "Complete", true } }));
var result = mongoCollection.AsQueryable().Where(o => o["Name"] == "A test record").ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment