mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
-
This commit is contained in:
@@ -11,7 +11,7 @@ namespace SqlSugar
|
||||
{
|
||||
public class RewritableMethods : IRewritableMethods
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///DataReader to Dynamic
|
||||
/// </summary>
|
||||
@@ -39,7 +39,7 @@ namespace SqlSugar
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string,object> DataReaderToDictionary(IDataReader reader)
|
||||
public Dictionary<string, object> DataReaderToDictionary(IDataReader reader)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
@@ -79,7 +79,7 @@ namespace SqlSugar
|
||||
var typeName = tType.Name;
|
||||
if (item.PropertyType.IsClass())
|
||||
{
|
||||
result.Add(name,DataReaderToDynamicList_Part(readerValues, item, reval));
|
||||
result.Add(name, DataReaderToDynamicList_Part(readerValues, item, reval));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -96,7 +96,7 @@ namespace SqlSugar
|
||||
}
|
||||
return reval;
|
||||
}
|
||||
private Dictionary<string,object> DataReaderToDynamicList_Part<T>(Dictionary<string, object> readerValues,PropertyInfo item, List<T> reval)
|
||||
private Dictionary<string, object> DataReaderToDynamicList_Part<T>(Dictionary<string, object> readerValues, PropertyInfo item, List<T> reval)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
var type = item.PropertyType;
|
||||
@@ -139,5 +139,21 @@ namespace SqlSugar
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy new Object
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sourceObject"></param>
|
||||
/// <returns></returns>
|
||||
public T TranslateCopy<T>(T sourceObject)
|
||||
{
|
||||
if (sourceObject == null) return default(T);
|
||||
else
|
||||
{
|
||||
var jsonString = SerializeObject(sourceObject);
|
||||
return DeserializeObject<T>(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,5 +25,6 @@ namespace SqlSugar
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
T DeserializeObject<T>(string value);
|
||||
T TranslateCopy<T>(T sourceObject);
|
||||
}
|
||||
}
|
||||
|
@@ -63,7 +63,8 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
return Tuple.Create<MappingTableList, MappingColumnList, IgnoreComumnList>(this.MappingTables,this.MappingColumns,this.IgnoreColumns);
|
||||
var result= Tuple.Create<MappingTableList, MappingColumnList, IgnoreComumnList>(this.MappingTables,this.MappingColumns,this.IgnoreColumns);
|
||||
return this.Context.RewritableMethods.TranslateCopy(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user