:
Model.Emails.Select(z => z.EmailAddress).DefaultIfEmpty("zzz").FirstOrDefault();
I thought you could do it all inside FirstOrDefault, but I was wrong - oh! However, I also forgot that when using DefaultIfEmpty you can just call First ().
Model.Emails.Select(z => z.EmailAddress).DefaultIfEmpty("zzz").First();
Of course, replace ZZZ with just "" (not string.empty, this is optional), but it's nice to see those posts where the explication is selected by default when you write it first.
source
share