public static Employee FindByKey(object key) { using(var context = new SoftUniEntities()) { return context.Employees.Find(key); } }
public static Employee FindByKey(object key) { using (var context = new SoftUniEntities()) { return(context.Employees.Find(key)); } }
public static void Add(Employee emp) { using (var context = new SoftUniEntities()) { context.Employees.Add(emp); context.SaveChanges(); } }
static void Main() { var context = new SoftUniEntities(); var employee = context.Employees.First(); // I hardly even understand the problem, there are no deliverables specified, it kinda sucks and I'm not doing it // Here, read something about best practices when updating records http://stackoverflow.com/questions/15336248/entity-framework-5-updating-a-record }
public static void Delete(Employee emp) { using (var context = new SoftUniEntities()) { context.Employees.Attach(emp); context.Employees.Remove(emp); context.SaveChanges(); } }