Created
April 26, 2012 14:53
-
-
Save ungood/2500145 to your computer and use it in GitHub Desktop.
Example of why methods are better
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is really elegant with methods, but really, really ugly with query expression | |
public IQueryable<User> SearchUsers(string firstName, string lastName) | |
{ | |
var query = getUserQuery(); | |
if(!string.IsNullOrEmpty(firstName)) | |
query = query.Where(user => user.FirstName == firstName); | |
if(!string.IsNullOrEmpty(lastName)) | |
query = query.Where(user => user.LastName == lastName); | |
return query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment