private bool Save() { bool result = false; using (var ctx = new EF6.RT2020Entities()) { var m = ctx.MarketSector.Find(_MarketSectorId); if (m == null) { m = new EF6.MarketSector(); m.MarketSectorId = new Guid(); ctx.MarketSector.Add(m); m.MarketSectorCode = txtMarketSectorCode.Text; } m.MarketSectorName = txtMarketSectorName.Text; m.MarketSectorName_Chs = txtMarketSectorNameAlt1.Text; m.MarketSectorName_Cht = txtMarketSectorNameAlt2.Text; m.ParentSector = (cboParentSector.SelectedValue == null) ? Guid.Empty : new Guid(cboParentSector.SelectedValue.ToString()); ctx.SaveChanges(); result = true; } return(result); }
private static string GetFormatedText(EF6.MarketSector 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.MarketSector object from the database using the given MarketSectorId /// </summary> /// <param name="marketSectorId">The primary key value</param> /// <returns>A EF6.MarketSector object</returns> public static EF6.MarketSector Get(Guid marketSectorId) { EF6.MarketSector result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.MarketSector.Where(x => x.MarketSectorId == marketSectorId).AsNoTracking().FirstOrDefault(); } return(result); }
/// <summary> /// Get a EF6.MarketSector object from the database using the given QueryString /// </summary> /// <param name="marketSectorId">The primary key value</param> /// <returns>A EF6.MarketSector object</returns> public static EF6.MarketSector Get(string whereClause) { EF6.MarketSector result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.MarketSector .SqlQuery(string.Format("Select * from MarketSector Where {0}", whereClause)) .AsNoTracking() .FirstOrDefault(); } return(result); }