HTML and CSS Reference
In-Depth Information
public void DeleteEmployee(Employee e)
{
NorthwindEntities db = new NorthwindEntities();
var data = from item in db.Employees
where item.EmployeeID == e.EmployeeID
select item;
Employee obj = data.SingleOrDefault();
db.DeleteObject(obj);
db.SaveChanges();
}
These CRUD methods are straightforward. The GetEmployees() method returns a collection of
Employee objects to the caller. The InsertEmployee() , UpdateEmployee() , and DeleteEmployee() methods
receive an Employee object as a parameter. This Employee object is then inserted into, updated in, or deleted
from the database. The Employee model class contains all the columns of the Employees table, but you
aren't using all of them. Hence, UpdateEmployee() assigns individual properties of the Employee object. The
Employee model class is shown in Figure 5-22.
Figure 5-22. Employee data model class
The application doesn't use all the properties of the Employee class. The properties of interest are
EmployeeID , TitleOfCourtesy , FirstName , LastName , BirthDate , Title , HireDate , Address , City , Country , and
HomePhone .
 
Search WWH ::




Custom Search