1

Which of the following statements is efficient for searching record from database using Entity Framework.

 var user = db.User.Where(u => u.id == userid).FirstOrDefault();
 // or
 var user = db.User.FirstOrDefault(u => u.id == userid);

Although both work.

1 Answer 1

5

They will both be evaluated to the same SQL.

Use SQL Profiler to see what SQL is created.

Sign up to request clarification or add additional context in comments.

1 Comment

This is such a simple query that it won't matter how you write it, it'll be the same SQL

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.