I am new to lambda expressions and delegates. I don't exactly know how to use them. So I have this method that I want to pass a lambda expression parameter to as such (x : x.name == "testName") so I can fetch Mongodb records that has "testname" as a name.
public List<BaseModel> get(*lambda expression here*)
{
List<User> users = Database.userCollectionObjs.Find(*lambda expression here*).ToList();
List<BaseModel> baseModels = new List<BaseModel>();
foreach (User user in users)
{
baseModels.Add(user);
}
return baseModels;
}
obviously if I do it like this:
List<User> users = Database.userCollectionObjs.Find(user => user.name == "testuser").ToList();
it works. but how do I pass this expression as a parameter to my get() and then insert it in the userCollectionObjs.Find