0

Consider the two following queries for the same object using LINQ->Entities.

Query 1:

var myOrd = ( from ord in _dbContext.Ords
              where ord.OrdId == myOrdId
              select ord ).FirstOrDefault();

vs.Query 2:

var myOrd = _dbContext.Ords.FirstOrDefault( o => o.OrdId == myOrdId );

First off, this question is directed towards variations on these queries as well, not just FirstOrDefault().

Is there any sort of trade off to using the "from" syntax vs. chaining method calls with lambdas, or is it more of matter of preference?

I apologize in advance for this being somewhat of a loaded question, and also if this has been answered anywhere else. I searched for a while and have yet to find what I'm looking for.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Eric Stallcup
  • 379
  • 2
  • 5
  • 15

0 Answers0