У меня есть следующий класс Person
с настраиваемым методом Where
:
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public string Where(Expression<Func<Person, bool>> predicate)
{
return String.Empty;
}
}
Как я могу получить Выражение
имена и значения параметров перечислимым способом?
Person p = new Person();
p.Where(i => i.Name == "Shlomi" && i.Age == 26);
Для создания строкового запроса с параметрами, присоединенными в соответствии с именем и значением выражения.
// Eventually I will convert the above into the following:
string Query = "select * from person where name = @Name AND Age = @Age";
SqlParameter[] param = new SqlParameter[] {
new SqlParameter("@Name","Shlomi"),
new SqlParameter("@Age","26")
};