AB can be null since your creating it with DefaultIfEmpty()
function, but also if ObjectA.Name
can be null; Contains()
in your second statement will throw an error. Similarly if ObjectB.ID or ObjectB.Name can be null when ObjectB is not null then your ObjectB != null
guard clause won't have the desired effect.
Try a simple enumaration of your objects to ensure the issue is with your first query
foreach( var item in searchObjects )
Console.WriteLine( item.Type );
Your redefining the searchObjects variable every itteration which I assume is something lost in the code-dump to SO, but worth a mention JIC.
Finally I'm not sure about the OpenAccess ORM since I've never used it, but this query would fail on the Dynamics CRM implementation of LINQ which doesn't support certain types of conditions in where clauses (I won't go into details because it's irrelevant, but you've broken all of them in this query :p). It's definitely worth browsing the documentation for gotcha's in a 3rd party LINQ implementation.