Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.68 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Code First POCO Design
  2. // project is a Project instance    
  3. if (project.Proposer is Lecturer)
  4. {
  5.    // do something
  6. } else if (project.Proposer is Student)
  7. {
  8.    // do something else
  9. }
  10.        
  11. public class Tag
  12. {
  13.     [Key]
  14.     public int ID { get; set; }
  15. }
  16.  
  17. public abstract class User
  18. {
  19.     [Key]
  20.     public int ID { get; set; }
  21.     public string Forename { get; set; }        
  22.     public string Surename { get; set; }
  23. }
  24.  
  25. public class Lecturer : User
  26. {
  27.     public IEnumerable<Tag> Forename { get; set; }
  28. }
  29.  
  30.  
  31. public class Student : User
  32. {
  33.     public IEnumerable<Tag> Forename { get; set; }
  34. }
  35.  
  36. public class Project
  37. {
  38.     [Key]
  39.     public int ID { get; set; }
  40.  
  41.     public User Proposer { get; set; }
  42. }