Exemple #1
0
        public List <EmployeesModel> GetEmployee(string _id_employee)
        {
            List <Employee> list = new List <Employee>();

            using (var db = new EmployeesEntities1())
            {
                var re = (from a in db.Employees
                          join b in db.Offices
                          on a.Id_Office equals b.Id_Office
                          where a.Id_Employee == _id_employee
                          select new EmployeesModel
                {
                    Id_Employee = _id_employee,
                    Name_Employee = a.Name_Employee,
                    Name_Office = b.Name_Office,
                    Position = a.Position
                }).ToList();
                return(re);
            }
        }
Exemple #2
0
        //private readonly string _id_employee;
        //private readonly string _id_office;
        public List <EmployeesModel> GetAllEmployees()
        {
            List <Employee> list = new List <Employee>();

            using (var db = new EmployeesEntities1()) //khoi tao db
            {
                var re = (from a in db.Employees
                          join b in db.Offices
                          on a.Id_Office equals b.Id_Office
                          select new EmployeesModel
                {
                    Id_Employee = a.Id_Employee,
                    Name_Employee = a.Name_Employee,
                    Name_Office = b.Name_Office,
                    Position = a.Position
                }).ToList();

                return(re);//.ToList() can set here;
            }
        }