Ejemplo n.º 1
0
 public static T GetConvertValue <T>(this IDataRecord dr, int i)
 {
     try
     {
         if (dr.IsDBNull(i))
         {
             return(default(T));
         }
         var result = dr.GetValue(i);
         return(UtilMethods.To <T>(result));
     }
     catch (Exception ex)
     {
         if (dr.GetFieldType(i) == UtilConstants.DateType)
         {
             return(UtilMethods.To <T>(dr.GetConvertDouble(i)));
         }
         if (dr.GetFieldType(i) == UtilConstants.GuidType)
         {
             var data = dr.GetString(i);
             if (data.ToString() == "")
             {
                 return(UtilMethods.To <T>(null));
             }
             else
             {
                 return(UtilMethods.To <T>(Guid.Parse(data.ToString())));
             }
         }
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 2
0
        public static T GetOther <T>(this IDataReader dr, int i)
        {
            if (dr.IsDBNull(i))
            {
                return(default(T));
            }
            var result = dr.GetValue(i);

            return(UtilMethods.To <T>(result));
        }
Ejemplo n.º 3
0
        public static Nullable <T> GetOtherNull <T>(this IDataReader dr, int i) where T : struct
        {
            if (dr.IsDBNull(i))
            {
                return(null);
            }
            var result = dr.GetValue(i);

            return(UtilMethods.To <T>(result));
        }
Ejemplo n.º 4
0
 public static T GetOther <T>(this IDataReader dr, int i)
 {
     try
     {
         if (dr.IsDBNull(i))
         {
             return(default(T));
         }
         var result = dr.GetValue(i);
         return(UtilMethods.To <T>(result));
     }
     catch (Exception ex)
     {
         return(OtherException <T>(dr, i, ex));
     }
 }
Ejemplo n.º 5
0
 private static T OtherException <T>(IDataRecord dr, int i, Exception ex)
 {
     if (dr.GetFieldType(i) == UtilConstants.DateType)
     {
         return(UtilMethods.To <T>(dr.GetConvertDouble(i)));
     }
     if (dr.GetFieldType(i) == UtilConstants.GuidType)
     {
         var data = dr.GetString(i);
         if (data.ToString() == "")
         {
             return(UtilMethods.To <T>(default(T)));
         }
         else
         {
             return(UtilMethods.To <T>(Guid.Parse(data.ToString())));
         }
     }
     throw new Exception(ex.Message);
 }
Ejemplo n.º 6
0
 public static T GetConvertValue <T>(this IDataRecord dr, int i)
 {
     try
     {
         if (dr.IsDBNull(i))
         {
             return(default(T));
         }
         var result = dr.GetValue(i);
         return(UtilMethods.To <T>(result));
     }
     catch (Exception ex)
     {
         if (dr.GetFieldType(i) == UtilConstants.DateType)
         {
             return(UtilMethods.To <T>(dr.GetConvertDouble(i)));
         }
         throw new Exception(ex.Message);
     }
 }