Guest User

Untitled

a guest
Jan 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public interface ICustomerAccountCalculation
  2. {
  3. Decimal Balance(int customerId);
  4. }
  5.  
  6. public interface ICustomerAccountCalculation
  7. {
  8. Decimal Balance(Customer customer);
  9. }
  10.  
  11. decimal balance = from c in Customers
  12. where c.CustomerId == customerId
  13. select c.Balance;
  14.  
  15. // caller with the object already loaded
  16. productService.process(product);
  17. // caller without the object loaded
  18. productService.process(new Product(productId));
  19.  
  20. // service method
  21. void process(Product product) {
  22.  
  23. // Ensure product is loaded, only if we need more fields.
  24. // We could extract this to a helper method.
  25. if (!product.isLoaded()) {
  26. product = database.getProduct(product.getId());
  27. }
  28.  
  29. ...
  30. }
Add Comment
Please, Sign In to add comment