Microsoft
70-516 · Question #162
You need to write a LINQ query that can be used against a ContosoEntities context object named context to find all parts that have a duplicate name. Which of the following queries should you use?…
The correct answer is B. context.Parts.GroupBy(p => p.Name).Where(g => g.Count() > 1). D. context.Parts.Where(p => context.Parts.Any(q =>. See the full explanation below for the reasoning.
Question
You need to write a LINQ query that can be used against a ContosoEntities context object named context to find all parts that have a duplicate name. Which of the following queries should you use? (Each correct answer presents a complete solution. Choose two).
Options
- Acontext.Parts.Any(p => context.Parts.Any(q => p.Name == q.Name));
- Bcontext.Parts.GroupBy(p => p.Name).Where(g => g.Count() > 1).
- Ccontext.Parts.SelectMany(p => context.Parts.
- Dcontext.Parts.Where(p => context.Parts.Any(q =>
How the community answered
(47 responses)- A4% (2)
- B83% (39)
- C13% (6)
Community Discussion
No community discussion yet for this question.