mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 04:35:29 +08:00
Optimize the code
This commit is contained in:
parent
148b299995
commit
5fb63604cf
@ -203,7 +203,7 @@ namespace SqlSugar
|
||||
{
|
||||
using (dataReader)
|
||||
{
|
||||
if (type.Name.StartsWith("KeyValuePair"))
|
||||
if (UtilMethods.IsKeyValuePairType(type))
|
||||
{
|
||||
return GetKeyValueList<T>(type, dataReader);
|
||||
}
|
||||
@ -231,7 +231,7 @@ namespace SqlSugar
|
||||
{
|
||||
using (dataReader)
|
||||
{
|
||||
if (type.Name.StartsWith("KeyValuePair"))
|
||||
if (UtilMethods.IsKeyValuePairType(type))
|
||||
{
|
||||
return await GetKeyValueListAsync<T>(type, dataReader);
|
||||
}
|
||||
@ -256,7 +256,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual List<T> DataReaderToListNoUsing<T>(Type type, IDataReader dataReader)
|
||||
{
|
||||
if (type.Name.StartsWith("KeyValuePair"))
|
||||
if (UtilMethods.IsKeyValuePairType(type))
|
||||
{
|
||||
return GetKeyValueList<T>(type, dataReader);
|
||||
}
|
||||
@ -275,7 +275,7 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual Task<List<T>> DataReaderToListNoUsingAsync<T>(Type type, IDataReader dataReader)
|
||||
{
|
||||
if (type.Name.StartsWith("KeyValuePair"))
|
||||
if (UtilMethods.IsKeyValuePairType(type))
|
||||
{
|
||||
return GetKeyValueListAsync<T>(type, dataReader);
|
||||
}
|
||||
|
@ -18,6 +18,10 @@ namespace SqlSugar
|
||||
{
|
||||
public class UtilMethods
|
||||
{
|
||||
public static bool IsKeyValuePairType(Type type)
|
||||
{
|
||||
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(KeyValuePair<,>);
|
||||
}
|
||||
public static DataTable ConvertDateTimeOffsetToDateTime(DataTable table)
|
||||
{
|
||||
if (!table.Columns.Cast<DataColumn>().Any(it => it.DataType == typeof(DateTimeOffset)))
|
||||
|
Loading…
Reference in New Issue
Block a user