Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- abstract class DbContext {} // to oczywiscie jest z EF
- class UserDTO
- {
- public string IPAddress { get; set; }
- public ICollection<Settings> Settings { get; set; }
- public string UserName { get; set; }
- }
- class UserService
- {
- public string IPAddress { get; set; }
- public ICollection<Settings> Settings { get; set; }
- public string UserName { get; set; }
- }
- class MyContext : DbContext
- {
- public DbSet<User> Users { get; set; }
- public DbSet<Settings> Settings { get; set; }
- public UserService GetUser(string IPAddress)
- {
- var result = Users.FirstOrDefault(x => x.IPAddress = IPAddress);
- if (result == null)
- {
- throw new Exception() //tutaj specyficzny exp
- }
- return Mapper.Map(result);
- }
- }
- public class Test
- {
- public static void Main()
- {
- // your code goes here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement