mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-01-26 21:38:32 +08:00
add db.Storageable(list).as(tablename)
This commit is contained in:
@@ -62,6 +62,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public IDeleteable<T> AS(string tableName)
|
public IDeleteable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
|
if (tableName == null) return this;
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
IsAs = true;
|
IsAs = true;
|
||||||
OldMappingTableList = this.Context.MappingTables;
|
OldMappingTableList = this.Context.MappingTables;
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ namespace SqlSugar
|
|||||||
#region Setting
|
#region Setting
|
||||||
public IInsertable<T> AS(string tableName)
|
public IInsertable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
|
if (tableName == null) return this;
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
IsAs = true;
|
IsAs = true;
|
||||||
OldMappingTableList = this.Context.MappingTables;
|
OldMappingTableList = this.Context.MappingTables;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public ISugarQueryable<T> AS(string tableName)
|
public ISugarQueryable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
|
if (tableName == null) return this;
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
return _As(tableName, entityName);
|
return _As(tableName, entityName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace SqlSugar
|
|||||||
List<T> dbDataList = new List<T>();
|
List<T> dbDataList = new List<T>();
|
||||||
List<KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>> whereFuncs = new List<KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>>();
|
List<KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>> whereFuncs = new List<KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>>();
|
||||||
Expression<Func<T, object>> whereExpression;
|
Expression<Func<T, object>> whereExpression;
|
||||||
|
private string asname { get; set; }
|
||||||
public Storageable(List<T> datas, SqlSugarProvider context)
|
public Storageable(List<T> datas, SqlSugarProvider context)
|
||||||
{
|
{
|
||||||
this.Context = context;
|
this.Context = context;
|
||||||
@@ -71,9 +72,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (this.allDatas.Count == 0)
|
if (this.allDatas.Count == 0)
|
||||||
return new StorageableResult<T>() {
|
return new StorageableResult<T>() {
|
||||||
AsDeleteable = this.Context.Deleteable<T>().Where(it => false),
|
AsDeleteable = this.Context.Deleteable<T>().AS(asname).Where(it => false),
|
||||||
AsInsertable = this.Context.Insertable(new List<T>()),
|
AsInsertable = this.Context.Insertable(new List<T>()).AS(asname),
|
||||||
AsUpdateable = this.Context.Updateable(new List<T>()),
|
AsUpdateable = this.Context.Updateable(new List<T>()).AS(asname),
|
||||||
InsertList = new List<StorageableMessage<T>>(),
|
InsertList = new List<StorageableMessage<T>>(),
|
||||||
UpdateList = new List<StorageableMessage<T>>(),
|
UpdateList = new List<StorageableMessage<T>>(),
|
||||||
DeleteList = new List<StorageableMessage<T>>(),
|
DeleteList = new List<StorageableMessage<T>>(),
|
||||||
@@ -90,7 +91,7 @@ namespace SqlSugar
|
|||||||
if (whereExpression == null && pkInfos.Any())
|
if (whereExpression == null && pkInfos.Any())
|
||||||
{
|
{
|
||||||
this.Context.Utilities.PageEach(allDatas, 300, item => {
|
this.Context.Utilities.PageEach(allDatas, 300, item => {
|
||||||
var addItems=this.Context.Queryable<T>().WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
|
var addItems=this.Context.Queryable<T>().AS(asname).WhereClassByPrimaryKey(item.Select(it => it.Item).ToList()).ToList();
|
||||||
dbDataList.AddRange(addItems);
|
dbDataList.AddRange(addItems);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -120,9 +121,9 @@ namespace SqlSugar
|
|||||||
var other = messageList.Where(it => it.StorageType == StorageType.Other).ToList();
|
var other = messageList.Where(it => it.StorageType == StorageType.Other).ToList();
|
||||||
StorageableResult<T> result = new StorageableResult<T>()
|
StorageableResult<T> result = new StorageableResult<T>()
|
||||||
{
|
{
|
||||||
AsDeleteable = this.Context.Deleteable<T>(),
|
AsDeleteable = this.Context.Deleteable<T>().AS(asname),
|
||||||
AsUpdateable = this.Context.Updateable(update.Select(it => it.Item).ToList()),
|
AsUpdateable = this.Context.Updateable(update.Select(it => it.Item).ToList()).AS(asname),
|
||||||
AsInsertable = this.Context.Insertable(inset.Select(it => it.Item).ToList()),
|
AsInsertable = this.Context.Insertable(inset.Select(it => it.Item).ToList()).AS(asname),
|
||||||
OtherList = other,
|
OtherList = other,
|
||||||
InsertList = inset,
|
InsertList = inset,
|
||||||
DeleteList = delete,
|
DeleteList = delete,
|
||||||
@@ -175,7 +176,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
List<IConditionalModel> conditList = new List<IConditionalModel>();
|
List<IConditionalModel> conditList = new List<IConditionalModel>();
|
||||||
SetConditList(itemList, whereColumns, conditList);
|
SetConditList(itemList, whereColumns, conditList);
|
||||||
var addItem = this.Context.Queryable<T>().Where(conditList).ToList();
|
var addItem = this.Context.Queryable<T>().AS(asname).Where(conditList).ToList();
|
||||||
this.dbDataList.AddRange(addItem);
|
this.dbDataList.AddRange(addItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -238,5 +239,11 @@ namespace SqlSugar
|
|||||||
var result = resolveExpress.Result;
|
var result = resolveExpress.Result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IStorageable<T> As(string tableName)
|
||||||
|
{
|
||||||
|
this.asname = tableName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public IUpdateable<T> AS(string tableName)
|
public IUpdateable<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
|
if (tableName == null) return this;
|
||||||
var entityName = typeof(T).Name;
|
var entityName = typeof(T).Name;
|
||||||
IsAs = true;
|
IsAs = true;
|
||||||
OldMappingTableList = this.Context.MappingTables;
|
OldMappingTableList = this.Context.MappingTables;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace SqlSugar
|
|||||||
IStorageable<T> SplitDelete(Func<StorageableInfo<T>, bool> conditions, string message = null);
|
IStorageable<T> SplitDelete(Func<StorageableInfo<T>, bool> conditions, string message = null);
|
||||||
IStorageable<T> SplitOther(Func<StorageableInfo<T>, bool> conditions, string message = null);
|
IStorageable<T> SplitOther(Func<StorageableInfo<T>, bool> conditions, string message = null);
|
||||||
StorageableResult<T> ToStorage();
|
StorageableResult<T> ToStorage();
|
||||||
|
IStorageable<T> As(string tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StorageableInfo<T> where T : class, new()
|
public class StorageableInfo<T> where T : class, new()
|
||||||
|
|||||||
Reference in New Issue
Block a user