Sunday, August 10, 2014

ordering records in queries within an ORM implementation?

Why do I care? Why can't I just do that on the C# side? Aren't this...

public List<Person> GetPersons()
{
   using (var db = new PersonContext())
   {
      var people = from person in db.People orderby person.Email select person;
      return people.ToList();
   }
}

 
 

...and this...

public List<Person> GetPersons()
{
   List<Person> results;
   using (var db = new PersonContext())
   {
      var people = from person in db.People select person;
      results = people.ToList();
   }
   return results.OrderBy(p => p.Email).ToList();
}

 
 

...basically equal?

No comments:

Post a Comment