Entity Framework query builder methods: why "it" and not lambdas?

Posted by nlawalker on Stack Overflow See other posts from Stack Overflow or by nlawalker
Published on 2010-06-15T21:44:28Z Indexed on 2010/06/15 23:22 UTC
Read the original article Hit count: 247

Filed under:
|

I'm just getting started with EF and a query like the following strikes me as odd:

var departmentQuery =
                schoolContext.Departments.Include("Courses").
                OrderBy("it.Name");

Specifically, what sticks out to me is "it.Name." When I was tooling around with LINQ to SQL, pretty much every filter in a query-builder query could be specified with a lambda, like, in this case, d => d.Name.

I see that there are overrides of OrderBy that take lambdas that return an IOrderedQueryable or an IOrderedEnumable, but those obviously don't have the Execute method needed to get the ObjectResult that can then be databound.

It seems strange to me after all I've read about how lambdas make so much sense for this kind of stuff, and how they are translated into expression trees and then to a target language - why do I need to use "it.Name"?

© Stack Overflow or respective owner

Related posts about c#

Related posts about entity-framework