I have a many-to-many relationship of products (p) and materials (m) and the products2materials table (p2m) as the many-to-many link.
I need to get
- all products that have materials assigned,
- all products with no materials assigned,
- and all materials with no products assigned.
Basically a union of what is there. However, since this will be a data filter, I need to filter out products and/or materials that do not match the search criteria (e.g. all products that start with "A", etc.).
How do I do this in LINQ-to-EF 4.1?
Many thanks!
Linq doesn't offer full outer join operation directly so your best choice is to try separate left and right join L2E queries and union them to single result set.
I would try something like (not tested):
Perhaps you will have to use
DefaultIfEmptyto enforce outer joins.