Пример #1
0
        public T GetFieldValue <T>(string fieldName)
        {
            object val  = GetFieldValue(fieldName);
            Type   type = typeof(T);

            return((T)Common_liby.Convert2Type(type, val));
        }
Пример #2
0
 /// <summary>
 /// 数据类型转换
 /// </summary>
 /// <param name="type">类型</param>
 /// <param name="val">数据值</param>
 /// <returns></returns>
 public static object Convert2Type(Type type, object val)
 {
     if (string.IsNullOrWhiteSpace(val?.ToString()) && type.IsValueType)
     {
         return(DBNull.Value);
     }
     //val = val.ToString();   //先转换成String类型再进行转换
     if (val is DBNull)
     {
         return(null);
     }
     else if (type == typeof(BoundaryPoint))
     {
         return(null);
     }
     else
     {
         return(Common_liby.Convert2Type(type, val));
     }
 }
Пример #3
0
 /// <summary>
 /// 数据类型转换
 /// </summary>
 /// <typeparam name="T">类型</typeparam>
 /// <param name="val">数据值</param>
 /// <returns></returns>
 public static T Convert2Type <T>(object val)
 {
     return(Common_liby.Convert2Type <T>(val));
 }