I'm writing something in the flavour of Enumerable.Where
in that takes a predicate of the form Func<T, bool>
. If the underlying T
implements INotifyPropertyChanged
, I'd like to be a bit more intelligent about re-evaluating the predicate.
I'm thinking about changing it to use Expression<Func<T, bool>>
, and then using the expression tree to find out which properties are used in the predicate. Then I can have my PropertyChanged
handler be a bit more intelligent.
My question: is this feasible? If the predicate's simple (e.g. x => x.Age > 18
), then the Expression
seems to have everything I need in it. Are there scenarios where I won't be able to see which properties are referenced?