private bool Save() { bool result = false; using (var ctx = new EF6.RT2020Entities()) { var jt = ctx.StaffJobTitle.Find(this.JobTitleId); if (jt == null) { jt = new EF6.StaffJobTitle(); jt.JobTitleId = new Guid(); ctx.StaffJobTitle.Add(jt); jt.JobTitleCode = txtJobTitleCode.Text; } jt.JobTitleName = txtJobTitleName.Text; jt.JobTitleName_Chs = txtJobTitleNameAlt1.Text; jt.JobTitleName_Cht = txtJobTitleNameAlt2.Text; ctx.SaveChanges(); result = true; } return(result); }
private static string GetFormatedText(EF6.StaffJobTitle target, string[] textField, string textFormatString) { for (int i = 0; i < textField.Length; i++) { PropertyInfo pi = target.GetType().GetProperty(textField[i]); textFormatString = textFormatString.Replace("{" + i.ToString() + "}", pi != null ? pi.GetValue(target, null).ToString() : string.Empty); } return(textFormatString); }
/// <summary> /// Get a EF6.StaffJobTitle object from the database using the given JobTitleId /// </summary> /// <param name="jobTitleId">The primary key value</param> /// <returns>A EF6.StaffJobTitle object</returns> public static EF6.StaffJobTitle Get(Guid jobTitleId) { EF6.StaffJobTitle result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.StaffJobTitle.Where(x => x.JobTitleId == jobTitleId).AsNoTracking().FirstOrDefault(); } return(result); }
/// <summary> /// Get a EF6.StaffJobTitle object from the database using the given QueryString /// </summary> /// <param name="jobTitleId">The primary key value</param> /// <returns>A EF6.StaffJobTitle object</returns> public static EF6.StaffJobTitle Get(string whereClause) { EF6.StaffJobTitle result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.StaffJobTitle .SqlQuery(string.Format("Select * from StaffJobTitle Where {0}", whereClause)) .AsNoTracking() .FirstOrDefault(); } return(result); }