public bool insert(List <mTag> items) { FIX_STAN789_T ent = new FIX_STAN789_T(); try { foreach (var p in ent.GetType().GetProperties()) { if (items.Any(k => k.NameInDb == p.Name)) { mTag t = items.First(k => k.NameInDb == p.Name); var targetType = IsNullableType(p.PropertyType) ? Nullable.GetUnderlyingType(p.PropertyType) : p.PropertyType; //Returns an System.Object with the specified System.Type and whose value is //equivalent to the specified object. object propertyVal = Convert.ChangeType(t.Value, targetType); //Set the value of the property p.SetValue(ent, propertyVal, null); } } } catch (Exception ex) { } ent.INCOMIN_DATE = DateTime.Now; // ! change!!! ent.WHEN = DateTime.Now; return(AddRecord(ent)); }
/// <summary> /// Get list of names of database table fields /// </summary> /// <returns></returns> public List <string> GetFields() { FIX_STAN789_T ent = new FIX_STAN789_T(); List <string> list = new List <string>(); foreach (var prop in ent.GetType().GetProperties()) { if (prop.PropertyType != typeof(DateTime) & !prop.Name.Equals("id", StringComparison.OrdinalIgnoreCase)) { string s = prop.Name; list.Add(s); } } return(list); }