Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. internal class DynamicPersonDetails<T>
  2. {
  3. private Database db;
  4.  
  5. public DynamicPersonDetails(Database database)
  6. {
  7. this.db= database;
  8. }
  9.  
  10. public DbResult GetByColumnName(string columnName, T value)
  11. {
  12. var sql =
  13. "SELECT * FROM person_detail WHERE "+columnName+"="value.toString();
  14.  
  15. return this.db.DoQuery(sql).FetchSingle();
  16. }
  17. }
  18.  
  19. public class EmailPersonDetails
  20. {
  21. private DynamicPersonDetails<string> dpd;
  22.  
  23. public EmailPersonDetails(DynamicpersonDetails<string> dpd)
  24. {
  25. this.dpd = dpd;
  26. }
  27.  
  28. public DbResult GetPersonDetailsByEmail(string email)
  29. {
  30. return this.dpd.GetByColumnName("email", email);
  31. }
  32. }
  33.  
  34. public class IdPersonDetails
  35. {
  36. private DynamicPersonDetails<int> dpd;
  37.  
  38. public EmailPersonDetails(DynamicpersonDetails<int> dpd)
  39. {
  40. this.dpd = dpd;
  41. }
  42.  
  43. public DbResult GetPersonDetailsById(int id)
  44. {
  45. return this.dpd.GetByColumnName("id", id);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement