mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-16 13:09:33 +08:00
Update db.UpdateNav
This commit is contained in:
parent
a2763d13d8
commit
5b5221e7b3
@ -105,16 +105,32 @@ namespace SqlSugar
|
||||
{
|
||||
if (isRoot && nav.Navigat.NavigatType != NavigateType.ManyToMany)
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
UpdateRoot();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Options != null && _Options.ManyToManyIsUpdateA)
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
UpdateRoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRoot()
|
||||
{
|
||||
if (_Options != null && _Options.RootFunc != null)
|
||||
{
|
||||
var updateable = this._Context.Updateable(_Roots);
|
||||
var exp= _Options.RootFunc as Expression<Action<IUpdateable<Root>>>;
|
||||
Check.ExceptionEasy(exp == null, "UpdateOptions.RootFunc is error", "UpdateOptions.RootFunc");
|
||||
var com= exp.Compile();
|
||||
com(updateable);
|
||||
updateable.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._Context.Updateable(_Roots).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,19 @@ namespace SqlSugar
|
||||
var insertData = x.InsertList.Select(it => it.Item).ToList();
|
||||
var updateData = x.UpdateList.Select(it => it.Item).ToList();
|
||||
Check.ExceptionEasy(pkColumn == null && NavColumn == null, $"The entity is invalid", $"实体错误无法使用导航");
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
if (_Options != null && _Options.CurrentFunc != null)
|
||||
{
|
||||
var updateable = x.AsUpdateable;
|
||||
var exp = _Options.CurrentFunc as Expression<Action<IUpdateable<TChild>>>;
|
||||
Check.ExceptionEasy(exp == null, "UpdateOptions.CurrentFunc is error", "UpdateOptions.CurrentFunc参数设置错误");
|
||||
var com = exp.Compile();
|
||||
com(updateable);
|
||||
updateable.ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
}
|
||||
InitData(pkColumn, insertData);
|
||||
if (_NavigateType == NavigateType.OneToMany)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -16,6 +17,8 @@ namespace SqlSugar
|
||||
public bool ManyToManyIsUpdateA { get; set; }
|
||||
public bool ManyToManyIsUpdateB { get; set; }
|
||||
public bool OneToManyDeleteAll { get; set; }
|
||||
public Expression RootFunc { get; set; }
|
||||
public Expression CurrentFunc { get; set; }
|
||||
}
|
||||
|
||||
public class InsertNavOptions
|
||||
|
Loading…
Reference in New Issue
Block a user