public ICollection <User> GetUsers()
 {
     using (var db = new HotelServicesDbContext())
     {
         return
             ((from user in db.Users
               join role in db.Roles on user.RoleId equals role.Id
               select new User
         {
             Fio = user.Fio,
             Login = user.Login,
             Password = user.Password,
             Id = user.Id,
             Role = role
         })
              .AsNoTracking().ToList());
     }
 }
 public User GetUserByLogin(string login)
 {
     using (var db = new HotelServicesDbContext())
     {
         return
             ((from user in db.Users
               join role in db.Roles on user.RoleId equals role.Id
               where user.Login == login
               select new User
         {
             Fio = user.Fio,
             Login = user.Login,
             Password = user.Password,
             Id = user.Id,
             Role = role
         })
              .AsNoTracking().FirstOrDefault());
     }
 }
示例#3
0
 public Order GetOrderById(string id)
 {
     using (var db = new HotelServicesDbContext())
     {
         return
             ((from order in db.Orders
               join service in db.ServiceInfos on order.ServiceId equals service.Id
               join user in db.Users on order.UserId equals user.Id
               where order.Id == id
               select new Order
         {
             Id = order.Id,
             Cost = order.Cost,
             IsPaid = order.IsPaid,
             OrderDate = order.OrderDate,
             Service = service,
             User = user,
             Units = order.Units
         }).AsNoTracking().FirstOrDefault());
     }
 }