Synchronization code

This commit is contained in:
sunkaixuan
2023-12-23 17:53:14 +08:00
parent 62c36484bf
commit f1e8b7309b
2 changed files with 10 additions and 0 deletions

View File

@@ -63,8 +63,14 @@ namespace SqlSugar.DbConvert
public T QueryConverter<T>(IDataRecord dr, int i)
{
var value = dr.GetValue(i);
if (value is byte[] && typeof(T) != UtilConstants.ByteArrayType)
{
value = Encoding.UTF8.GetString((byte[])value);
}
return (T)UtilMethods.ChangeType2(value, typeof(T));
}
}

View File

@@ -750,6 +750,10 @@ namespace SqlSugar
}
public static object ChangeType2(object value, Type type)
{
if (value is byte[]&&type==UtilConstants.StringType)
{
return Encoding.UTF8.GetString(value as byte[]);
}
if (value == null && type.IsGenericType) return Activator.CreateInstance(type);
if (value == null) return null;
if (type == value.GetType()) return value;