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); } }
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)); }
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)); }
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)); } }
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); }
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); } }