mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update db.Utils
This commit is contained in:
parent
19ae5b1845
commit
2862fdb53f
@ -1193,7 +1193,7 @@ namespace SqlSugar
|
||||
}
|
||||
else if (entityType.IsAnonymousType() || isComplexModel)
|
||||
{
|
||||
result = this.Context.Utilities.DataReaderToDynamicList<TResult>(dataReader);
|
||||
result = this.Context.Utilities.DataReaderList<TResult>(dataReader);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ namespace SqlSugar
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="reader"></param>
|
||||
/// <returns></returns>
|
||||
public List<T> DataReaderToDynamicList<T>(IDataReader reader)
|
||||
public List<T> DataReaderList<T>(IDataReader reader)
|
||||
{
|
||||
using (reader)
|
||||
{
|
||||
@ -305,6 +305,24 @@ namespace SqlSugar
|
||||
return this.DeserializeObject<dynamic>(this.SerializeObject(deserializeObject));
|
||||
|
||||
}
|
||||
public List<T> DataTableToList<T>(DataTable table)
|
||||
{
|
||||
List<Dictionary<string, object>> deserializeObject = new List<Dictionary<string, object>>();
|
||||
Dictionary<string, object> childRow;
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
childRow = new Dictionary<string, object>();
|
||||
foreach (DataColumn col in table.Columns)
|
||||
{
|
||||
var addItem = row[col];
|
||||
if (addItem == DBNull.Value)
|
||||
addItem = null;
|
||||
childRow.Add(col.ColumnName, addItem);
|
||||
}
|
||||
deserializeObject.Add(childRow);
|
||||
}
|
||||
return this.DeserializeObject<List<T>>(this.SerializeObject(deserializeObject));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Cache
|
||||
|
@ -13,7 +13,7 @@ namespace SqlSugar
|
||||
SqlSugarClient Context { get; set; }
|
||||
ExpandoObject DataReaderToExpandoObject(IDataReader reader);
|
||||
List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader);
|
||||
List<T> DataReaderToDynamicList<T>(IDataReader reader);
|
||||
List<T> DataReaderList<T>(IDataReader reader);
|
||||
string SerializeObject(object value);
|
||||
T DeserializeObject<T>(string value);
|
||||
T TranslateCopy<T>(T sourceObject);
|
||||
|
Loading…
Reference in New Issue
Block a user