Add db.UpdateNav(+2)

This commit is contained in:
sunkaixuan
2022-10-24 09:03:09 +08:00
parent 2263ba5706
commit fe8a9cda76
7 changed files with 56 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ namespace SqlSugar
{
public partial class UpdateNavProvider<Root, T> where T : class, new() where Root : class, new()
{
internal UpdateNavRootOptions _RootOptions { get; set; }
public List<Root> _Roots { get; set; }
public List<object> _ParentList { get; set; }
public List<object> _RootList { get; set; }

View File

@@ -934,6 +934,20 @@ namespace SqlSugar
result.UpdateNavProvider = provider;
return result;
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data, UpdateNavRootOptions rootOptions) where T : class, new()
{
return UpdateNav(new List<T>() { data},rootOptions);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas, UpdateNavRootOptions rootOptions) where T : class, new()
{
var result = new UpdateNavTaskInit<T, T>();
var provider = new UpdateNavProvider<T, T>();
provider._Roots = datas;
provider._RootOptions = rootOptions;
provider._Context = this;
result.UpdateNavProvider = provider;
return result; ;
}
#endregion
#region DbFirst

View File

@@ -709,6 +709,14 @@ namespace SqlSugar
{
return ScopedContext.UpdateNav(datas);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas, UpdateNavRootOptions rootOptions) where T : class, new()
{
return this.ScopedContext.UpdateNav(datas, rootOptions);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data, UpdateNavRootOptions rootOptions) where T : class, new()
{
return this.ScopedContext.UpdateNav(data, rootOptions);
}
public SqlSugarClient CopyNew()
{
return new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));

View File

@@ -5,13 +5,24 @@ using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
namespace SqlSugar
{
public class DeleteNavOptions
{
public bool ManyToManyIsDeleteA { get; set; }
public bool ManyToManyIsDeleteB { get; set; }
}
}
public class InsertNavRootOptions
{
public string IgnoreColumns { get; set; }
public string[] UpdateColumns { get; set; }
}
public class UpdateNavRootOptions
{
public string IgnoreColumns { get; set; }
public string[] UpdateColumns { get; set; }
public bool IsInsert { get; set; }
}
public class UpdateNavOptions
{
public bool ManyToManyIsUpdateA { get; set; }

View File

@@ -213,7 +213,9 @@ namespace SqlSugar
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();
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>(List<T> datas) where T : class, new ();
UpdateNavTaskInit<T, T> UpdateNav<T>(T data,UpdateNavRootOptions rootOptions) where T : class, new();
UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas, UpdateNavRootOptions rootOptions) where T : class, new();
#endregion
}

View File

@@ -214,9 +214,17 @@ namespace SqlSugar
{
return this.Context.UpdateNav(data);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas,UpdateNavRootOptions rootOptions) where T : class, new()
{
return this.Context.UpdateNav(datas, rootOptions);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data, UpdateNavRootOptions rootOptions) where T : class, new()
{
return this.Context.UpdateNav(data,rootOptions);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas) where T : class, new()
{
return this.Context.UpdateNav(datas);
return this.Context.UpdateNav(datas);
}
#endregion

View File

@@ -765,6 +765,14 @@ namespace SqlSugar
{
return ScopedContext.UpdateNav(datas);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(T data,UpdateNavRootOptions rootOptions) where T : class, new()
{
return ScopedContext.UpdateNav(data);
}
public UpdateNavTaskInit<T, T> UpdateNav<T>(List<T> datas, UpdateNavRootOptions rootOptions) where T : class, new()
{
return ScopedContext.UpdateNav(datas);
}
public SqlSugarClient CopyNew()
{
return new SqlSugarClient(UtilMethods.CopyConfig(this.Ado.Context.CurrentConnectionConfig));