Created
May 3, 2011 23:31
-
-
Save house9/954461 to your computer and use it in GitHub Desktop.
Simple.Data with MongoDB
This file contains 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
using Simple.Data; | |
using Simple.Data.MongoDB; | |
// connect | |
dynamic db = Database.Opener.OpenMongo("mongodb://localhost:27017/myDB"); | |
// insert | |
dynamic user = new ExpandoObject(); | |
user.FirstName = "Joe"; | |
user.LastName = "Smith"; | |
user.Email = "jsmith@test.com"; | |
db.Users.Insert(user); | |
// find | |
dynamic existingUser = db.Users.FindByEmail("jsmith@test.com"); |
Not sure if you got it to work?
Maybe post at the authors repo https://github.com/craiggwilson/Simple.Data.MongoDB
I only messed around with this for a few days, and that was months ago
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the speedy reply!
I tried FindAll(), FindByAll(), FindAllBy() and FindBy(). All of them seem to throw exceptions except FindAll, so I'm guessing that FindAll() is the correct method name, and that the MongoDB adapter just doesn't implement it yet.
I'm going through the source code now to see if I can find where it's failing and fix it.
BTW, I realize it's not best practice to grab everything from a Mongo collection. Did you implement anything similar to say, "Limit()"? If not, I might try to implement that. Right now I just want to grab the latest 5 items from a collection.