Which code segment should you use?

You are developing an order processing application that uses the Entity Framework against a SQL Server database. The application has a method that returns orders filtered by date.
The Order class is shown below.

You must filter the data on the SQL server before it is returned to the application server.
You need to return orders more recent than the entered date.
Which code segment should you use?
A.

B.

C.

D.

microsoft-exams

3 thoughts on “Which code segment should you use?

  1. It’s B.

    It’s not A because ToList will query the db and put the result in memory. Where() will be executed on memory items.
    It’s not C because this will query the db and put the result in memory. Where() will be executed on memory items.
    It’s not D because, well, same thing as A, basically.

    It’s B because the query will not be executed with the first line. The Where() gets executed in SQL Server, which performs a lot better.

Leave a Reply

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


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