You have to use the ! suffix operator… The lambda expression isn’t executed, it will never fail on null reference. For some reason, MS decided to keep Linq.Expressions on C# version 5 or so, we can’t do anything about the ?. operator. Thanks god the ! operator is allowed there.
We use the expression to make the validation path from it, which is why the condition fails. I guess we could pattern-match the null-check conditions, but ehh, it isn’t exactly simple and then the API doesn’t serve even the purpose of simplifying the validation paths. You can also use the AddModelError("OperationFinalizationSectino/SelectedFinalizationDate", ...) overload and avoid this automatic translation entirely.
That overload is not found and also this.AddRawModelError() not found. No suggestions for using namespaces.
LE: nevermind, found them in DotVVM’s Context
I have used AddRawModelError because AddModelError with first param as string is warned of as being obsolete.