code_junkie

Do you ToList()?

Nov 12th, 2011
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // This is just an example... imagine this is on the server only. It's the
  2. // basic method that gets the list of clients.
  3. private IEnumerable<Client> GetClients()
  4. {
  5. var result = MyDataContext.Clients;
  6.  
  7. return result.AsEnumerable();
  8. }
  9.  
  10. // This method here is actually called by the user...
  11. public Client[] GetClientsForLoggedInUser()
  12. {
  13. var clients = GetClients().Where(client=> client.Owner == currentUser);
  14.  
  15. return clients.ToArray();
  16. }
  17.  
  18. private IQueryable<Client> GetClients()
  19. {
  20. var result = MyDataContext.Clients;
  21.  
  22. return result.AsQueryable();
  23. }
Add Comment
Please, Sign In to add comment