public static GlobalMessage ModifyCMEmailType(CMEmailType cMEmailType) { if (cMEmailType != null) { try { var e = Db.CMEmailTypes.Where(p => p.CMEmailTypeId == cMEmailType.CMEmailTypeId).SingleOrDefault(); e.EmailType = cMEmailType.EmailType; .. .. .. .. .. .. .. Db.SaveChanges(); return new GlobalMessage("", GlobalEnum.MessageStatus.Success, GlobalEnum.MessageCss.Success); } catch (Exception ex) { ErrorWriter.WriteError(ex, "FunctionName --> InsertTable", ""); } } return new GlobalMessage("", GlobalEnum.MessageStatus.Error, GlobalEnum.MessageCss.Error); }
Now it depends on if you want to update entire row or what. Usually we assign properties like you are doing but we can also assign whole object to fetched object like e = cMEmailType; but do need to update the ID again.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)