public IEnumerable<Employee> GetAll() { var command = connection.CreateCommand(); command.CommandText = "select * from Employees"; using (command) using (var reader = command.ExecuteReader()) { while (reader.Read()) { var newEmployee = new Employee { Id = (int)reader["Id"], Code = (string)reader["Code"], Name = (string)reader["Name"], Birthdate = (DateTime)reader["Birthdate"], }; yield return newEmployee; } } }
static IEnumerable<Employee> GetAllEmployee() { var connection = new SqlConnection("Server=.\\SQLEXPRESS;Database=LamedhPos;Integrated Security=SSPI"); var command = connection.CreateCommand(); command.CommandText = "select * from Employees"; connection.Open(); var reader = command.ExecuteReader(); //var result = new List<Employee>(); while (reader.Read()) { var newEmployee = new Employee { Id = (int)reader["Id"], Code = (string)reader["Code"], Name = (string)reader["Name"], Birthdate = (DateTime)reader["Birthdate"], }; //result.Add(newEmployee); yield return newEmployee; } //return result; }
public ActionResult Edit(Employee employee) { employeeRepo.Save(employee); return RedirectToAction("Index"); }
public void Save(Employee entity) { throw new NotImplementedException(); }