2
例子中,我下面的代碼lambda exprssion的動態變化體?
public class Person
{
public bool FirstNameIsActive { get; set; }
public bool SecondNameIsActive { get; set; }
}
如果我想通過屬性過濾FirstNameIsActive
Func<Person, bool> predicate1 = x => x.FirstNameIsActive == true;
如果我想通過屬性過濾SecondNameIsActive
Func<Person, bool> predicate2 = x => x.SecondNameIsActive == true;
我想在運行時改變我謂詞到
Func<Person, bool> predicate = x => x.PropertyThatIWant == true;
你想如何使用它? – Grundy