开发者

WCF Ria, LINQ to Entity projection, filtering, deferred execution

Lets say I've got the following entities

  • User

    • UserID
    • UserName
    • UserNameAsLower
    • Profile (Navigation property)
  • Profile

    • UserID
    • Email
    • EmailAsLower
    • Language

and I want to return a consolidated object, lets call it a UserDTO, but remove some of the fi开发者_JAVA百科elds that we don't want the user to see (AsLower stuff)

  • UserDTO
    • UserID
    • UserName
    • Email
    • Language

if I write a LINQ query as follows and then apply filtering criteria on it, will it execute at that point since the filter criteria is being applied to the projected class property names?

public IQueryable<UserDTO> GetUsers() 
{
   IQueryable<UserDTO> users = (from u in Entities.Users select new UserDTO() { UserID = u.UserID, UserName = u.UserName, Email = u.Profile.Email, Language = u.Profile.Email });
   users = users.Where( u => u.UserName.Contains("Admin") );

   return users;
}

The reason I'm asking is if the database table behind it happens to be really large (millions of records), I want to make sure it doesn't try to load it into memory first.


RIA will execute the LINQ query with all applied filters and only serialize back the results.

Order of operations is this: client constructs IQueryable, client enumerates IQueryable, RIA turns IQueryable.Expression into GET request, server parses GET request into Expression tree and reconstructs IQueryable, server executes expression using IQueryProvider, server serializes response to client.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜