typesafe NotifyPropertyChanged using linq expressions

What does the code that raises this look like? I’m guessing it is something like:

NotifyOfPropertyChange(() => SomeVal);

which is implicitly:

NotifyOfPropertyChange(() => this.SomeVal);

which does a capture of this, and pretty-much means that the expression tree must be constructed (with Expression.Constant) from scratch each time. And then you parse it each time. So the overhead is definitely non-trivial.

Is is too much though? That is a question only you can answer, with profiling and knowledge of your app. It is seen as OK for a lot of MVC usage, but that isn’t (generally) calling it in a long-running tight loop. You need to profile against a desired performance target, basically.

Leave a Comment