-
-
Save house9/954461 to your computer and use it in GitHub Desktop.
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 = "[email protected]"; | |
db.Users.Insert(user); | |
// find | |
dynamic existingUser = db.Users.FindByEmail("[email protected]"); |
I think it is FindAll() or FindByAll() or FindAllBy()
the wiki entry must have some typo because it uses both and one is definitely not correct
see https://github.com/markrendle/Simple.Data/wiki/Finding-data
haven't been working with c# for last few months and can't remember which one
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.
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
Great library, but is there any way I can get every item in a collection, without filtering? I've tried everything I can think of, including 'db.Users' or 'db.Users.FindAll()', but nothing seems to work.