private bool Save() { bool result = false; using (var ctx = new EF6.RT2020Entities()) { var item = ctx.SmartTag4Staff.Find(_SmartTagId); if (item == null) { item = new EF6.SmartTag4Staff(); item.TagId = Guid.NewGuid(); item.TagCode = txtTagCode.Text; ctx.SmartTag4Staff.Add(item); } item.TagName = txtTagName.Text; item.TagName_Chs = txtTagNameAlt1.Text; item.TagName_Cht = txtTagNameAlt2.Text; item.Priority = Convert.ToInt32(txtPriority.Text); ctx.SaveChanges(); result = true; } return(result); }
private static string GetFormatedText(EF6.SmartTag4Staff 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.SmartTag4Staff object from the database using the given TagId /// </summary> /// <param name="tagId">The primary key value</param> /// <returns>A EF6.SmartTag4Staff object</returns> public static EF6.SmartTag4Staff Get(Guid tagId) { EF6.SmartTag4Staff result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SmartTag4Staff.Where(x => x.TagId == tagId).AsNoTracking().FirstOrDefault(); } return(result); }
public static EF6.SmartTag4Staff GetByTagCode(string code) { EF6.SmartTag4Staff result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SmartTag4Staff.Where(x => x.TagCode == code).FirstOrDefault(); } return(result); }
/// <summary> /// Get a EF6.SmartTag4Staff object from the database using the given QueryString /// </summary> /// <param name="tagId">The primary key value</param> /// <returns>A EF6.SmartTag4Staff object</returns> public static EF6.SmartTag4Staff Get(string whereClause) { EF6.SmartTag4Staff result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SmartTag4Staff .SqlQuery(string.Format("Select * from SmartTag4Staff Where {0}", whereClause)) .AsNoTracking() .FirstOrDefault(); } return(result); }