mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update db.Storageable
This commit is contained in:
parent
50728c26dc
commit
4c798e151c
@ -52,7 +52,7 @@ namespace OrmTest
|
||||
throw new Exception("Unit Insert");
|
||||
}
|
||||
List<UinitBlukTable> list2 = new List<UinitBlukTable>();
|
||||
for (int i = 0; i <= 20; i++)
|
||||
for (int i = 1; i <= 20; i++)
|
||||
{
|
||||
UinitBlukTable data = new UinitBlukTable()
|
||||
{
|
||||
@ -70,15 +70,18 @@ namespace OrmTest
|
||||
.SplitDelete(it=>it.Item.Id>10)
|
||||
.SplitIgnore(it=>it.Item.Id==2)
|
||||
.SplitError(it => it.Item.Id == 3,"id不能等于3")
|
||||
.SplitError(it => it.Item.Id == 4, "id不能等于4")
|
||||
.SplitError(it => it.Item.Id == 5, "id不能等于5")
|
||||
.WhereColumns(it=>it.Id)
|
||||
.ToStorage();
|
||||
x.AsDeleteable.ExecuteCommand();
|
||||
x.AsInsertable.ExecuteCommand();
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
db.DbMaintenance.TruncateTable<UinitBlukTable>();
|
||||
}
|
||||
public class UinitBlukTable
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey =true)]
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SqlSugar.SugarColumn(IsNullable =true)]
|
||||
|
@ -220,6 +220,15 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public IDeleteable<T> WhereColumns(Expression<Func<T, object>> columns)
|
||||
{
|
||||
if (columns != null)
|
||||
{
|
||||
tempPrimaryKeys = DeleteBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public IDeleteable<T> RemoveDataCache()
|
||||
{
|
||||
this.RemoveCacheFunc = () =>
|
||||
|
@ -84,7 +84,7 @@ namespace SqlSugar
|
||||
var other = messageList.Where(it => it.StorageType == StorageType.Other).ToList();
|
||||
StorageableResult<T> result = new StorageableResult<T>()
|
||||
{
|
||||
AsDeleteable = this.Context.Deleteable(delete.Select(it => it.Item).ToList()),
|
||||
AsDeleteable = this.Context.Deleteable<T>(),
|
||||
AsUpdateable = this.Context.Updateable(update.Select(it => it.Item).ToList()),
|
||||
AsInsertable = this.Context.Insertable(inset.Select(it => it.Item).ToList()),
|
||||
OtherList = other,
|
||||
@ -95,6 +95,12 @@ namespace SqlSugar
|
||||
IgnoreList = ignore,
|
||||
TotalList = messageList
|
||||
};
|
||||
if (this.columns != null)
|
||||
{
|
||||
result.AsUpdateable.WhereColumns(columns);
|
||||
result.AsDeleteable.WhereColumns(columns);
|
||||
}
|
||||
result.AsDeleteable.Where(delete.Select(it => it.Item).ToList());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -459,11 +459,16 @@ namespace SqlSugar
|
||||
|
||||
private void PreToSql()
|
||||
{
|
||||
|
||||
UpdateBuilder.PrimaryKeys = GetPrimaryKeys();
|
||||
if (this.IsWhereColumns)
|
||||
{
|
||||
foreach (var pkName in UpdateBuilder.PrimaryKeys)
|
||||
{
|
||||
if (WhereColumnList != null&& WhereColumnList.Count()>0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var isContains = this.UpdateBuilder.DbColumnInfoList.Select(it => it.DbColumnName.ToLower()).Contains(pkName.ToLower());
|
||||
Check.Exception(isContains == false, "Use UpdateColumns().WhereColumn() ,UpdateColumns need {0}", pkName);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ namespace SqlSugar
|
||||
IDeleteable<T> Where(string whereString, SugarParameter parameter);
|
||||
IDeleteable<T> Where(string whereString, SugarParameter[] parameters);
|
||||
IDeleteable<T> Where(string whereString, List<SugarParameter> parameters);
|
||||
IDeleteable<T> WhereColumns(Expression<Func<T, object>> columns);
|
||||
IDeleteable<T> EnableDiffLogEvent(object businessData = null);
|
||||
IDeleteable<T> RemoveDataCache();
|
||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||
|
Loading…
Reference in New Issue
Block a user