Entity Framework, select with "if exist" -like condition

I'll try to explain my problem clearly, since it's quite complicated.

I've the following scheme on my DB with tables:


Meaning that one element of A is related to many elements of B etc. The direction of the arrow is about the foreign keys. B as an id_A , but A as not id_B etc.

My aim is to select "all the elements of A with at least one element of E following the condition "CONDITION".

I've tried a cascade of "where" and "any" with lines long as my arm but didn't find any success.

Is there any simple way to do this?

Thanks a lot


You can do

from a in A
where a.Bs.Any(b => b.Cs.Any(c => c.Ds.Any(d => d.Es.Any(e => CONDITION(e)))))

I'm sorry, I've found a solution using a sql server view.

It is simple, needs 4 inner joins and 4 conditions.

Thanks again!

Need Your Help

Command line tool to extract key value pairs from XML files

xml unix xml-parsing utilities

Quite regularly I need to extract key value pairs from XML files. Is there an easy-to-use UNIX(-style) command line tool available for this?