Created
August 19, 2010 16:14
-
-
Save mikeobrien/538255 to your computer and use it in GitHub Desktop.
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
using (var mongo = Mongo.Create("mongodb://user:password@localhost/Test")) | |
{ | |
// Some strongly typed filter, I want a document with a number of 2 | |
Expression<Func<User, bool>> filterExpression = u => u.Number == 2; | |
// A NoRM specific object, not important | |
var filter = new Expando(); | |
// I need to pull the name "Number" and the value 2 | |
// and programatically pass it to the NoRM expando object. | |
// IE: filter.Set("Number", 2); | |
// This is psuedocode here of course: | |
foreach (var filter in filterExpression.Body) | |
filter.Set(filter.Name, filter.Value); | |
// NoRM specific, not important | |
var user = mongo.GetCollection<User>().FindOne(filter); | |
Console.WriteLine(user != null ? user.Name : "Nothing found"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment