Microsoft Exam Questions

Which expression should you use?

The application must provide a component part list for any product. The component part list must give the quantity of
each distinct part that is required to manufacture that product.

You need to create a LINQ expression that delivers a a result of type IEnumerable<Tuple<int,Part>> to meet the requirements.
Which expression should you use?

A.
IEnumerable<Tuple<int, Part>> result = part.Children
.Distinct()
.GroupBy(p => p)
.Select(g => Tuple.Create(g.Count(), g.Key));

B.
IEnumerable<Tuple<int, Part>> result = part.Descendants
.GroupBy(p => p)
.Select(g => Tuple.Create(g.Count(), g.Key));

C.
IEnumerable<Tuple<int, Part>> result = part.Descendants
.ToDictionary(c => c)
.Select(d => Tuple.Create(d.Value.Children.Count(), d.Key));

D.
IEnumerable<Tuple<int, Part>> result = part.Children
.GroupBy(p => p)
.Select(g => Tuple.Create(g.Count(), g.Key));

E.
IEnumerable<Tuple<int, Part>> result = part.Descendants
.Distinct()
.GroupBy(p => p)
.Select(g => Tuple.Create(g.Count(), g.Key));