public void Create(Department dpt) { using (var ctx = new LYLQEntities()) { ctx.Departments.Add(dpt); ctx.SaveChanges(); } }
public void Update(Department dpt) { using (var ctx = new LYLQEntities()) { var dbDpts = from dbDpt in ctx.Departments where dbDpt.Code == dpt.Code select dbDpt; var dbModelDpt = dbDpts.First(); dbModelDpt.Name = dpt.Name; dbModelDpt.UpdatedBy = dpt.UpdatedBy; dbModelDpt.UpdatedDate = DateTime.Now; ctx.SaveChanges(); } }