Update db.DeleteNav

This commit is contained in:
sunkaixuan 2023-05-01 13:57:11 +08:00
parent 8ee44ff527
commit 6be209c59b
10 changed files with 78 additions and 3 deletions

View File

@ -31,7 +31,9 @@ namespace SqlSugar
if (IsDeleteA())
{
if (!_IsDeletedParant)
SetContext(() => this._Context.Deleteable(parentList).ExecuteCommand());
SetContext(() => this._Context.Deleteable(parentList)
.EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent == true, _RootOptions?.DiffLogBizData)
.ExecuteCommand());
}
var aids = _ParentList.Select(it => parentPkColumn.PropertyInfo.GetValue(it)).ToList();

View File

@ -25,7 +25,9 @@ namespace SqlSugar
}
if (!_IsDeletedParant)
SetContext(() => this._Context.Deleteable(prentList).ExecuteCommand());
SetContext(() => this._Context.Deleteable(prentList)
.EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent==true,_RootOptions?.DiffLogBizData)
.ExecuteCommand());
var ids = _ParentList.Select(it => parentPkColumn.PropertyInfo.GetValue(it)).ToList();
var childList = GetChildList<TChild>().In(thisFkColumn.DbColumnName, ids).ToList();

View File

@ -20,7 +20,9 @@ namespace SqlSugar
if (!_IsDeletedParant)
SetContext(() => this._Context.Deleteable(parentList).ExecuteCommand());
SetContext(() => this._Context.Deleteable(parentList)
.EnableDiffLogEventIF(_RootOptions?.IsDiffLogEvent == true, _RootOptions?.DiffLogBizData)
.ExecuteCommand());
var ids = _ParentList.Select(it => parentColumn.PropertyInfo.GetValue(it)).ToList();

View File

@ -16,6 +16,7 @@ namespace SqlSugar
public EntityInfo _ParentEntity { get; set; }
public EntityColumnInfo _ParentPkColumn { get; set; }
public SqlSugarProvider _Context { get; set; }
internal DeleteNavRootOptions _RootOptions { get; set; }
public bool _IsDeletedParant { get; set; }
public List<string> _WhereList = new List<string>();
public List<SugarParameter> _Parameters = new List<SugarParameter>();

View File

@ -1153,6 +1153,25 @@ namespace SqlSugar
{
return DeleteNav(this.Queryable<T>().Where(whereExpression).ToList());
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new()
{
return DeleteNav(new List<T>() { data }, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new()
{
var result = new DeleteNavTaskInit<T, T>();
result.deleteNavProvider = new DeleteNavProvider<T, T>();
result.deleteNavProvider._Roots = datas;
result.deleteNavProvider._Context = this;
result.deleteNavProvider._RootOptions = options;
return result;
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new()
{
return DeleteNav(this.Queryable<T>().Where(whereExpression).ToList(),options);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new()
{
return UpdateNav(new List<T>() { data });

View File

@ -769,6 +769,18 @@ namespace SqlSugar
{
return ScopedContext.DeleteNav(whereExpression);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new()
{
return ScopedContext.DeleteNav(data, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new()
{
return ScopedContext.DeleteNav(datas, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new()
{
return ScopedContext.DeleteNav(whereExpression, options);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new()
{
return ScopedContext.UpdateNav(data);

View File

@ -12,6 +12,11 @@ namespace SqlSugar
public bool ManyToManyIsDeleteA { get; set; }
public bool ManyToManyIsDeleteB { get; set; }
}
public class DeleteNavRootOptions
{
public bool IsDiffLogEvent { get; set; }
public object DiffLogBizData { get; set; }
}
public class InsertNavRootOptions
{
public string[] IgnoreColumns { get; set; }

View File

@ -228,6 +228,9 @@ namespace SqlSugar
DeleteNavTaskInit<T, T> DeleteNav<T>(T data) where T : class, new();
DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas) where T : class, new();
DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T,bool>> whereExpression) where T : class, new();
DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new();
DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new();
DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new();
UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new ();
UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas) where T : class, new ();
UpdateNavTaskInit<T, T> UpdateNav<T>(T data,UpdateNavRootOptions rootOptions) where T : class, new();

View File

@ -230,6 +230,20 @@ namespace SqlSugar
{
return this.Context.DeleteNav(whereExpression);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new()
{
return this.Context.DeleteNav(data, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new()
{
return this.Context.DeleteNav(datas, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new()
{
return this.Context.DeleteNav(whereExpression, options);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new()
{
return this.Context.UpdateNav(data);

View File

@ -815,6 +815,21 @@ namespace SqlSugar
{
return ScopedContext.DeleteNav(whereExpression);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(T data, DeleteNavRootOptions options) where T : class, new()
{
return ScopedContext.DeleteNav(data, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(List<T> datas, DeleteNavRootOptions options) where T : class, new()
{
return ScopedContext.DeleteNav(datas, options);
}
public DeleteNavTaskInit<T, T> DeleteNav<T>(Expression<Func<T, bool>> whereExpression, DeleteNavRootOptions options) where T : class, new()
{
return ScopedContext.DeleteNav(whereExpression, options);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data) where T : class, new()
{
return ScopedContext.UpdateNav(data);