I'm dealing with some arrays that are being returned to me from a 3rd party API. Sometimes these come back as null
. I am able to handle everything elegantly with LINQ except for the null case. I came up with something like this:
IEnumerable<Thing> procs = APICall(foo, bar);
var result = from proc in procs ?? Enumerable.Empty<Thing>()
where proc != null
select Transform(proc);
The use of the coalescing operator here chafes a little. Am I missing something from LINQ that handles this?