Thanks for the quick response. I've decided to use your suggestion
and do the null check before I pass in the lambda. I think you are
On Jun 10, 7:37 pm, Jeremy Skinner <
jer...@jeremyskinner.co.uk> wrote:
> Hi Robin,
> You are correct - _columnValueFunc is a delegate that invokes the lambda
> expression to return the value. If Country is null, then a
> NullReferenceException will occur as the Title property cannot be accessed.
>
> I'm in two minds as to what the Grid should do in this situation. As it
> stands at the moment, null checking is the responsibility of the developer.
> However, I could change it to wrap the delegate invocation in a try-catch
> and silently return null if a NullReferenceException occurs. The downside
> here is that it would make debugging problems more difficult.
>
> Anyway, for now putting a null-check inside the lambda should solve the
> problem:
>
> column.For(x => x.Country == null ? null : x.Country.Title);
>
> Jeremy
>