It depends on what shape you want for the returned data. I suspect the problem may be with the nested
Select
. Try:
.SelectMany(company => company.clients.Select(client => new
{
name = client.name,
policy = client.policy != null ? client.policy : company.policy,
}))
Alternatively, you could return both properties and then select the correct one in your client code:
.SelectMany(company => company.clients.Select(client => new
{
client.name,
client.policy,
company_policy = company.policy,
}))
.AsEnumerable()
.Select(client => new
{
client.name,
policy = client.policy ?? client.company_policy,
});