// This method inserts a new record in the table. // Change this method to alter how records are inserted. public static int Insert(Location x) { Chapter08 db = Chapter08.CreateDataContext(); db.Locations.Add(x); db.SubmitChanges(); return(1); }
// This method deletes a record in the table. // Change this method to alter how records are deleted. public static int Delete(Location x) { Chapter08 db = Chapter08.CreateDataContext(); db.Locations.Remove(x); db.SubmitChanges(); return(1); }
// This method updates a record in the table. // Change this method to alter how records are updated. public static int Update(Location original_x, Location x) { Chapter08 db = Chapter08.CreateDataContext(); db.Locations.Attach(original_x); original_x.City = x.City; original_x.State = x.State; original_x.Creation = x.Creation; original_x.Modified = x.Modified; db.SubmitChanges(); return(1); }
// This method updates a record in the table. // Change this method to alter how records are updated. public static int Update(Person original_x, Person x) { Chapter08 db = Chapter08.CreateDataContext(); db.Persons.Attach(original_x); original_x.FirstName = x.FirstName; original_x.LastName = x.LastName; original_x.LocationID = x.LocationID; original_x.Creation = x.Creation; original_x.Modified = x.Modified; db.SubmitChanges(); return(1); }
// This method retrieves all Persons. // Change this method to alter how records are retrieved. public static IQueryable <Person> GetAllPersons() { Chapter08 db = Chapter08.CreateDataContext(); return(db.Persons); }
// This method retrieves a single Location. // Change this method to alter how that record is received. public static Location GetLocation(Int64 ID) { Chapter08 db = Chapter08.CreateDataContext(); return(db.Locations.Where(x => x.ID == ID).FirstOrDefault()); }
// This method retrieves all Locations. // Change this method to alter how records are retrieved. public static IQueryable <Location> GetAllLocations() { Chapter08 db = Chapter08.CreateDataContext(); return(db.Locations); }
// This method retrieves Persons by Location. // Change this method to alter how records are retrieved. public static IQueryable <Person> GetPersonsByLocation(Int64 ID) { Chapter08 db = Chapter08.CreateDataContext(); return(db.Locations.Where(x => x.ID == ID).SelectMany(x => x.Persons)); }