Advertisement
Guest User

Untitled

a guest
Jun 25th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. public class Student
  2. {
  3. public string StudentId { get; set; }
  4. public string Gender { get; set; }
  5. public List<EmailAddresses> emailAddresses { get; set; }
  6. }
  7.  
  8. public class EmailAddresses
  9. {
  10. public string EmailAddress { get; set; }
  11. }
  12.  
  13. StudentId EmailAddresses IsPreferred Number TelephoneType
  14. 123456789 maryjoe@gmail.com FALSE 5556565 Present Evening Phone
  15. 123456789 maryjoe@gmail.com FALSE 8885566 Permanent Day Phone
  16. 123456789 mary.joe@cuu.edu TRUE 5556565 Present Evening Phone
  17. 123456789 mary.joe@cuu.edu TRUE 8885566 Permanent Day Phone
  18. 456789123 dh@mycollege.edu TRUE 7513150 Business Day Phone
  19. 456789123 donna.hill@cu.edu TRUE 4123300 Present Day Phone
  20. 456789123 donna.hill@cu.edu FALSE 4123300 Present Day Phone
  21.  
  22. public List<Student> GetStudentData()
  23. {
  24. List<Student> dataStudent;
  25. using (IDbConnection connection = RepositoryHelper.OpenConnection())
  26. {
  27. dataStudent = connection.Query<dynamic>(
  28. "mystoredprocedure",
  29. commandType: CommandType.StoredProcedure)
  30. .GroupBy(x => x.StudentId)
  31. .Select(x => new Student
  32. {
  33. StudentId = x.First().StudentId,
  34. Gender = x.First().Gender,
  35. emailAddresses = x.Select(ea => new EmailAddresses
  36. {
  37. EmailAddress = ea.emailAddresses
  38. }).ToList()
  39. }).ToList();
  40.  
  41. return dataStudent;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement