Created
December 11, 2014 13:23
-
-
Save pjsvis/780d930b87ce8ea5cc48 to your computer and use it in GitHub Desktop.
Using LINQ to simplify business rules
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
// Ref: http://odetocode.com/Articles/739.aspx | |
// Using LINQ to simplify business rules | |
Employee employee = | |
new Employee { ID = 1, Name = | |
"Poonam", DepartmentID = 1 }; | |
Func<Employee, bool>[] validEmployeeRules = | |
{ | |
e => e.DepartmentID > 0, | |
e => !String.IsNullOrEmpty(e.Name), | |
e => e.ID > 0 | |
}; | |
bool isValidEmployee = | |
validEmployeeRules.All(rule => rule(employee)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment