I have a first query that returns a set of entities:
var resultSet = ....query....ToList();
which would return A, B, C, D, E
The entities inside this set are organized into chains because they have a reference (prevEntityId) pointing to the same type of entity, i.e.:
A -> B -> D
C -> E
I would like to write a second query so that only A and C are now returned but I have no idea how to write it.
I would prefer your answer with linq methods (like .Where()) instead of the new linq syntax.
Thank you
Update: sorry I initially used the wrong vocabulary in my question with the term "foreign key". Actually an entity has a direct reference to the previous entity so to elect an entity in the second query, there must be no other entity that references it. I thought it would take 2 queries but if you think it can be done in one...