mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Add Storageable(List<Dictionary<string,object>> dictionaryList,string tableName)
This commit is contained in:
parent
e86b83f8a6
commit
ee948ce685
@ -66,6 +66,12 @@ namespace OrmTest
|
|||||||
.WhereColumns("id").ToStorage();
|
.WhereColumns("id").ToStorage();
|
||||||
x4.AsDeleteable.ExecuteCommand();
|
x4.AsDeleteable.ExecuteCommand();
|
||||||
|
|
||||||
|
var dicList = db.Queryable<Order>().Take(10).ToDictionaryList();
|
||||||
|
var x5 =
|
||||||
|
db.Storageable(dicList, "order")
|
||||||
|
.WhereColumns("id").ToStorage();
|
||||||
|
x5.AsUpdateable.IgnoreColumns("items").ExecuteCommand();
|
||||||
|
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
Console.WriteLine("#### Saveable End ####");
|
Console.WriteLine("#### Saveable End ####");
|
||||||
}
|
}
|
||||||
|
@ -543,6 +543,30 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region DataTable
|
#region DataTable
|
||||||
|
public DataTable DictionaryListToDataTable(List<Dictionary<string, object>> list)
|
||||||
|
{
|
||||||
|
DataTable result = new DataTable();
|
||||||
|
if (list.Count == 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
var columnNames = list.First();
|
||||||
|
foreach (var item in columnNames)
|
||||||
|
{
|
||||||
|
result.Columns.Add(item.Key,item.Value==null?typeof(object):item.Value.GetType());
|
||||||
|
}
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
var row = result.NewRow();
|
||||||
|
foreach (var key in item.Keys)
|
||||||
|
{
|
||||||
|
row[key] = item[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Rows.Add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public dynamic DataTableToDynamic(DataTable table)
|
public dynamic DataTableToDynamic(DataTable table)
|
||||||
{
|
{
|
||||||
List<Dictionary<string, object>> deserializeObject = new List<Dictionary<string, object>>();
|
List<Dictionary<string, object>> deserializeObject = new List<Dictionary<string, object>>();
|
||||||
|
@ -38,5 +38,6 @@ namespace SqlSugar
|
|||||||
Task PageEachAsync<T>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task> action);
|
Task PageEachAsync<T>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task> action);
|
||||||
Task PageEachAsync<T, ResultType>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task<ResultType>> action);
|
Task PageEachAsync<T, ResultType>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task<ResultType>> action);
|
||||||
List<IConditionalModel> JsonToConditionalModels(string json);
|
List<IConditionalModel> JsonToConditionalModels(string json);
|
||||||
|
DataTable DictionaryListToDataTable(List<Dictionary<string, object>> dictionaryList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,6 +365,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return this.Context.Storageable(data);
|
return this.Context.Storageable(data);
|
||||||
}
|
}
|
||||||
|
public StorageableDataTable Storageable(List<Dictionary<string,object>> dictionaryList,string tableName)
|
||||||
|
{
|
||||||
|
DataTable dt = this.Context.Utilities.DictionaryListToDataTable(dictionaryList);
|
||||||
|
dt.TableName = tableName;
|
||||||
|
return this.Context.Storageable(dt);
|
||||||
|
}
|
||||||
|
|
||||||
public IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new()
|
public IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user