This commit is contained in:
sunkaixuan
2017-06-07 14:25:33 +08:00
parent 94fde8cd12
commit 6f68a92950
2 changed files with 12 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ namespace SqlSugar
private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) }); private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) });
private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) }); private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) });
private static readonly MethodInfo getEnum = typeof(IDataRecordExtensions).GetMethod("GetEnum"); private static readonly MethodInfo getEnum = typeof(IDataRecordExtensions).GetMethod("GetEnum");
private static readonly MethodInfo getConvertString = typeof(IDataRecordExtensions).GetMethod("GetConvertString");
private static readonly MethodInfo getConvertFloat = typeof(IDataRecordExtensions).GetMethod("GetConvertFloat"); private static readonly MethodInfo getConvertFloat = typeof(IDataRecordExtensions).GetMethod("GetConvertFloat");
private static readonly MethodInfo getConvertBoolean = typeof(IDataRecordExtensions).GetMethod("GetConvertBoolean"); private static readonly MethodInfo getConvertBoolean = typeof(IDataRecordExtensions).GetMethod("GetConvertBoolean");
private static readonly MethodInfo getConvertByte = typeof(IDataRecordExtensions).GetMethod("GetConvertByte"); private static readonly MethodInfo getConvertByte = typeof(IDataRecordExtensions).GetMethod("GetConvertByte");
@@ -216,7 +217,7 @@ namespace SqlSugar
break; break;
} }
if (method == null&&bindPropertyType == PubConst.StringType) { if (method == null&&bindPropertyType == PubConst.StringType) {
method = getString; method = getConvertString;
} }
if (method == null) if (method == null)
method = getOtherNull.MakeGenericMethod(bindPropertyType); method = getOtherNull.MakeGenericMethod(bindPropertyType);

View File

@@ -118,6 +118,16 @@ namespace SqlSugar
return reval; return reval;
} }
public static string GetConvertString(this IDataRecord dr, int i)
{
if (dr.IsDBNull(i))
{
return null;
}
var reval =Convert.ToString(dr.GetValue(i));
return reval;
}
public static Nullable<T> GetOtherNull<T>(this IDataReader dr, int i) where T : struct public static Nullable<T> GetOtherNull<T>(this IDataReader dr, int i) where T : struct
{ {
if (dr.IsDBNull(i)) if (dr.IsDBNull(i))