Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using System;
  2.  
  3. abstract class DbContext {} // to oczywiscie jest z EF
  4.  
  5. class UserDTO
  6. {
  7. public string IPAddress { get; set; }
  8. public ICollection<Settings> Settings { get; set; }
  9. public string UserName { get; set; }
  10. }
  11.  
  12. class UserService
  13. {
  14. public string IPAddress { get; set; }
  15. public ICollection<Settings> Settings { get; set; }
  16. public string UserName { get; set; }
  17. }
  18.  
  19. class MyContext : DbContext
  20. {
  21. public DbSet<User> Users { get; set; }
  22. public DbSet<Settings> Settings { get; set; }
  23.  
  24. public UserService GetUser(string IPAddress)
  25. {
  26. var result = Users.FirstOrDefault(x => x.IPAddress = IPAddress);
  27. if (result == null)
  28. {
  29. throw new Exception() //tutaj specyficzny exp
  30. }
  31. return Mapper.Map(result);
  32. }
  33. }
  34.  
  35. public class Test
  36. {
  37.  
  38.  
  39. public static void Main()
  40. {
  41. // your code goes here
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement