How should you complete the code?

DRAG DROP
You have a class named Customer and a class named Order.
The customer class has a property named Orders that contains a list of Order objects.
The Order class has a property named OrderDate that contains the date of the Order.
You need to create a LINQ query that returns all of the customers who had at least one order during the year 2005. You write the following code.


How should you complete the code? To answer, drag the appropriate code elements to the correct targets in the answer area. Each code element may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Select and Place:


microsoft-exams

8 thoughts on “How should you complete the code?

  1. List customersWithOrdersIn2005 = customers.Where(c => c.Orders.Any(o => o.OrderDate.Year == 2005)).ToList();

    1. I think it should be like this:
      customers.Select(c => c.Orders.Where(o => o.OrderDate.Year == 2005)).ToList();

  2. I believe the provided answer is incorrect, The Where clause accepts a boolean condition, it should go like this: Where, Any, =>, ==

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.