Guest User

Untitled

a guest
Jan 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public abstract class Account
  2. {
  3. public Guid PKey { get; set; } = Guid.NewGuid();
  4. public string Owner { get; set; }
  5. }
  6.  
  7. public class CheckingAccount : Account
  8. {
  9. public int Fee { get; set; }
  10. }
  11.  
  12. public class SavingAccount : Account
  13. {
  14. public double InterestRate { get; set; }
  15. }
  16.  
  17. using(MyContext ctx = new Context())
  18. {
  19. CheckingAccount ca = ctx.CheckingAccount.Find(pKey);
  20. SavingAccount sa = ctx.SavingAccount.Find(pKey);
  21.  
  22. if(ca != null)
  23. {
  24. Console.WriteLine("It's a CheckingAccount!");
  25. }
  26. else if(sa != null)
  27. {
  28. Console.WriteLine("It's a SavingAccount!");
  29. }
  30. }
Add Comment
Please, Sign In to add comment