none
LINQ Performance in Retrieving the data... RRS feed

  • Question

  • Is there any performance difference between the following two statements?

    assuming there's a Id property of the student.

     

    var q = db.Table.Where(c => c.Id.Equals(Id));

     

    var q = from c in db.Table

         where c.Id.Equals(Id)

         select c;

     


    what can you say folks?

     

    tnx!

     

    Best Regards


    Tuesday, December 20, 2011 1:20 AM

Answers

  • No.  The two actually compile into identical statements - there is no performance difference.

     

    The language integrated query syntax is just a way to make something (potentially) more readable.  It uses the exact same methods (IQueryable<T>.Where) to implement the filtering.

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Tuesday, December 20, 2011 1:26 AM