How to use Entity Framework to work with many-to-many relationships?

What about this: var employeesNotAssignedToProject = db.Employees. Select(e => e). Where(e => (e.Projects.

Count(c => c. ProjectID == 1)) == 0) I haven't tested this, but basically what it does is it selects only those employees where their Projects collection does not include the project in question by checking the count of projects with the given id.

It does work. Thanks. – jsteele Aug 12 '09 at 14:05 2!Any() is more efficient than Count() == 0, though.

– Craig Stuntz Aug 13 '09 at 1:04 how would that look in the above example? – Jason Miesionczek Aug 13 '09 at 1:59 1 db.Employees. Select(e => e).

Where(e => (!e.Projects. Any(c => c. ProjectID == 1))) – Craig Stuntz Aug 13 '09 at 13:41 cool, good to know.

– Jason Miesionczek Aug 13 '09 at 13:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions