public void Update(DataLayer.Model.FileReplace_File model) { using (var context = new DataLayer.DAL.MyDBContext()) { model.UpdateTime = DateTime.Now; context.FileReplace_File.Attach(model); context.Entry(model).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void Update(DataLayer.Model.FileReplace_RuleConfig model) { using (var context = new DataLayer.DAL.MyDBContext()) { var info = context.FileReplace_RuleConfig.FirstOrDefault(k => k.RuleConfigID == model.RuleConfigID); if (null == info) { return; } info.IsFileContent = model.IsFileContent; info.IsFileName = model.IsFileName; info.IsIgnoreCase = model.IsIgnoreCase; info.IsRegex = model.IsRegex; info.IsWholeMatch = model.IsWholeMatch; info.Name = model.Name; info.NewContent = model.NewContent; info.OldContent = model.OldContent; info.UpdateTime = DateTime.Now; context.FileReplace_RuleConfig.Attach(info); context.Entry(info).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }