public static SqlParameter TransProperty2Param(PropertyVal p) { SqlParameter param = new SqlParameter(); param = SafeSQL.CreateInputParam(p.pName, GetDbType(p.pType), p.pValue); return(param); }
/// <summary> /// 回傳非null的屬性 /// </summary> /// <param name="pObject"></param> /// <returns>Return PropertyVal List</returns> public static List <PropertyVal> GetPropertiesVal(object pObject, bool excludeNull = true) { List <PropertyVal> propertyList = new List <PropertyVal>(); if (pObject != null) { foreach (var prop in pObject.GetType().GetProperties()) { if (prop.GetValue(pObject, null) != null) { PropertyVal val = new PropertyVal(); val.pName = prop.Name; val.pValue = prop.GetValue(pObject, null).ToString(); val.pType = prop.GetValue(pObject, null).GetType(); propertyList.Add(val); } } } return(propertyList); }