私は匿名クラスを返しています:
var clients = from c in this.ClientRepository.SearchClientByTerm(term, 10)
select new
{
id = c.Id,
line1 = c.Address.Line1 ?? "Unknown Information ..."
};
問題は Address が nullable であることです。つまり、それが null の場合、100 万個に爆発します。
私が考えることができる最もエレガントな解決策はこれでした...
line1 = c.Address != null && c.Address.Line1 != null
? c.Address.Line1 : "Unknown Information ..."
より良い方法はありますか?、null 合体演算子を使用する機能を失い、null かどうかを確認する必要があるのは好きではありません。