Using Entity Framework 4, and given:
ObjectSet<Thing> AllThings = Context.CreateObjectSet<Thing>;
public IQuery开发者_开发技巧able<Thing> ByNameA(String name)
{
    IQueryable<Thing> query =  from o in AllThings 
                               where o.Name == name 
                               select o;
    return query;
}
public IQueryable<Thing> ByNameB(String name)
{
    return AllThings.Where((o) => o.Name == name);
}
Both return IQueryable<> instances, and thus the query doesn't hit the server until something like ToList() is called, right? Is it purely readability that is the difference, or are the using fundamentally different technologies on the back-end?
These compile to nearly identical code.
The first syntax translates directly, by the compiler, into methods with the names provided in the second syntax.
The main difference between these two methods is really just that you're using a different syntax, and that you're assigning to a temporary variable (query) instead of just returning the result directly. However, they are, for all practical purposes, identical.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论