Created
September 28, 2017 00:38
-
-
Save saip106/801b22ef536e977b58b7503e02c2639c to your computer and use it in GitHub Desktop.
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
public Person[] Get(SearchCriteria searchCriteria) | |
{ | |
using(var dbContext = new MyDbContext()) | |
{ | |
var query = dbContext.Persons; | |
if(!string.IsNullOrWhitespace(searchCriteria.FirstName)) | |
{ | |
query = query.Where(x => x.FirstName.Contains(searchCriteria.FirstName)); | |
} | |
if(!string.IsNullOrWhitespace(searchCriteria.Zipcode)) | |
{ | |
query = query.Where(x => x.Zipcode == searchCriteria.Zipcode); | |
} | |
return query.ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment