private bool Save() { bool result = false; using (var ctx = new EF6.RT2020Entities()) { var item = ctx.SupplierAddressType.Find(_AddressTypeId); if (item == null) { item = new EF6.SupplierAddressType(); item.AddressTypeId = new Guid(); item.AddressTypeCode = txtTypeCode.Text; ctx.SupplierAddressType.Add(item); } item.AddressTypeName = txtTypeName.Text; item.AddressTypeName_Chs = txtTypeNameAlt1.Text; item.AddressTypeName_Cht = txtTypeNameAlt2.Text; item.Priority = Convert.ToInt32(txtPriority.Text); ctx.SaveChanges(); result = true; } return(result); }
private static string GetFormatedText(EF6.SupplierAddressType 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.SupplierAddressType object from the database using the given AddressTypeId /// </summary> /// <param name="addressTypeId">The primary key value</param> /// <returns>A EF6.SupplierAddressType object</returns> public static EF6.SupplierAddressType Get(Guid addressTypeId) { EF6.SupplierAddressType result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SupplierAddressType.Where(x => x.AddressTypeId == addressTypeId).AsNoTracking().FirstOrDefault(); } return(result); }
/// <summary> /// Get a EF6.SupplierAddressType object from the database using the given QueryString /// </summary> /// <param name="addressTypeId">The primary key value</param> /// <returns>A EF6.SupplierAddressType object</returns> public static EF6.SupplierAddressType Get(string whereClause) { EF6.SupplierAddressType result = null; using (var ctx = new EF6.RT2020Entities()) { result = ctx.SupplierAddressType .SqlQuery(string.Format("Select * from SupplierAddressType Where {0}", whereClause)) .AsNoTracking() .FirstOrDefault(); } return(result); }