Guest User

Untitled

a guest
Jun 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public T GetBusinessObject (lambda_criteria)
  2.  
  3. Employee emp = BOC.GetBusinessObject( Employee.ID=123 )
  4.  
  5. T GetBusinesObject<T>( Func<T, bool> predicate )
  6. {
  7. return this.FirstOrDefault( predicate );
  8. }
  9.  
  10. T GetBusinessObject<T>(Predicate<T> constraint) where T : BO
  11.  
  12. GetBusinessObject<Employee>( e => e.ID = 123 )
  13.  
  14. BOC<Employee> boc = ...
  15. // checks exactly 1 match, throws if no match
  16. var emp = boc.Single(e => e.ID = 123);
  17. // checks at most 1 match, null if no match
  18. var emp = boc.SingleOrDefault(e => e.ID = 123);
  19. // checks at least one match, throws if no match
  20. var emp = boc.First(e => e.ID = 123);
  21. // returns first match, null if no match
  22. var emp = boc.FirstOrDefault(e => e.ID = 123);
Add Comment
Please, Sign In to add comment