0

I have the following two database tables. A group contains multiple members.

Groups: Id (int) | Name (int)

Members: Id (int) | GroupId (int) | IsExpert (bit)

I need to write a linq to sql query that returns the Groups that has no experts. Need some help

2 Answers 2

1

Your answer should be those groups where the groups' collection of members doesn't contain any experts (ie !Any)

context.Groups.Where(group -> !group.Members.Any(member => member.IsExpert));
Sign up to request clarification or add additional context in comments.

Comments

0
var GroupsWithNoExperts =
DBDataContext.Groups.Where(
    g=>!DBDataContext.Members.Any(m=>m.GroupID==g.Id && m.IsExpert
));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.