public void Location_Update(Location item) { using (WorkSchedule context = new WorkSchedule()) { context.Entry<Location>(context.Locations.Attach(item)).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public List<Location> Location_List() { using (WorkSchedule context = new WorkSchedule()) { var results = from item in context.Locations orderby item.Name select item; return results.ToList(); } }
public List<DAL.Entities.POCOs.EmployeeSkillDirectory> GetEmployeeBySkill() { using (WorkSchedule context = new WorkSchedule()) { var results = from cat in context.EmployeeSkills select new DAL.Entities.POCOs.EmployeeSkillDirectory { Skill = cat.Skill.Description, Name = cat.Employee.FirstName + "," + cat.Employee.LastName, Phone = cat.Employee.HomePhone, Level = cat.Level.ToString(), YOE = cat.YearsOfExperience }; return results.ToList(); // this is similar to .Dump() in Linqpad } }
public List<Location> Location_List() { using (var context = new WorkSchedule()) { //retrieve the data from the specialEvent table //to do so we will use the DBset in eRestaurantContext //call SoecialEvents (done by mapping) //method syntax //return context.SpecialEvents.OrderBy(x => x.Description).ToList(); //query syntax var results = from item in context.Locations select item; return results.ToList(); } }
public void Location_Add(Location item) { //input into this method at the instance level using (WorkSchedule context = new WorkSchedule()) { //create a pointer variable for the instance type //set this pointer to null Location added = null; //setup the add request for the dbcontext added = context.Locations.Add(item); //saving the changes will cause the .Add to execute //commits the Add to database //evaluates the annotation (validation) on your entity context.SaveChanges(); } }