|
@ -9,7 +9,7 @@ namespace SqlSugar |
|
|
{ |
|
|
{ |
|
|
public class DeleteNavTaskInit<Root,T> where T : class, new() where Root : class, new() |
|
|
public class DeleteNavTaskInit<Root,T> where T : class, new() where Root : class, new() |
|
|
{ |
|
|
{ |
|
|
public List<T> Roots { get; set; } |
|
|
internal List<T> Roots { get; set; } |
|
|
internal SqlSugarProvider Context { get; set; } |
|
|
internal SqlSugarProvider Context { get; set; } |
|
|
internal DeleteNavProvider<Root, Root> deleteNavProvider { get; set; } |
|
|
internal DeleteNavProvider<Root, Root> deleteNavProvider { get; set; } |
|
|
|
|
|
|
|
@ -17,7 +17,7 @@ namespace SqlSugar |
|
|
{ |
|
|
{ |
|
|
this.Context = deleteNavProvider._Context; |
|
|
this.Context = deleteNavProvider._Context; |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
Func<DeleteNavTask<Root, TChild>> func = () => deleteNavProvider.ThenInclude(expression); |
|
|
Func<DeleteNavProvider<Root, TChild>> func = () => deleteNavProvider.ThenInclude(expression); |
|
|
result.PreFunc = func; |
|
|
result.PreFunc = func; |
|
|
result.Context = this.Context; |
|
|
result.Context = this.Context; |
|
|
return result; |
|
|
return result; |
|
@ -26,7 +26,7 @@ namespace SqlSugar |
|
|
{ |
|
|
{ |
|
|
this.Context = deleteNavProvider._Context; |
|
|
this.Context = deleteNavProvider._Context; |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
Func<DeleteNavTask<Root, TChild>> func = () => deleteNavProvider.ThenInclude(expression); |
|
|
Func<DeleteNavProvider<Root, TChild>> func = () => deleteNavProvider.ThenInclude(expression); |
|
|
result.PreFunc = func; |
|
|
result.PreFunc = func; |
|
|
result.Context = this.Context; |
|
|
result.Context = this.Context; |
|
|
return result; |
|
|
return result; |
|
@ -35,11 +35,11 @@ namespace SqlSugar |
|
|
public class DeleteNavTask<Root, T> where T : class, new() where Root : class, new() |
|
|
public class DeleteNavTask<Root, T> where T : class, new() where Root : class, new() |
|
|
{ |
|
|
{ |
|
|
public SqlSugarProvider Context { get; set; } |
|
|
public SqlSugarProvider Context { get; set; } |
|
|
public Func<DeleteNavTask<Root, T>> PreFunc { get; set; } |
|
|
public Func<DeleteNavProvider<Root, T>> PreFunc { get; set; } |
|
|
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new() |
|
|
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new() |
|
|
{ |
|
|
{ |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
Func<DeleteNavTask<Root, TChild>> func = () => PreFunc().ThenInclude(expression); |
|
|
Func<DeleteNavProvider<Root, TChild>> func = () => PreFunc().ThenInclude(expression); |
|
|
result.PreFunc = func; |
|
|
result.PreFunc = func; |
|
|
result.Context = this.Context; |
|
|
result.Context = this.Context; |
|
|
return result; |
|
|
return result; |
|
@ -47,7 +47,7 @@ namespace SqlSugar |
|
|
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new() |
|
|
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new() |
|
|
{ |
|
|
{ |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>(); |
|
|
Func<DeleteNavTask<Root, TChild>> func = () => PreFunc().ThenInclude(expression); |
|
|
Func<DeleteNavProvider<Root, TChild>> func = () => PreFunc().ThenInclude(expression); |
|
|
result.PreFunc = func; |
|
|
result.PreFunc = func; |
|
|
result.Context = this.Context; |
|
|
result.Context = this.Context; |
|
|
return result; |
|
|
return result; |
|
@ -62,16 +62,19 @@ namespace SqlSugar |
|
|
} |
|
|
} |
|
|
public bool ExecuteCommand() |
|
|
public bool ExecuteCommand() |
|
|
{ |
|
|
{ |
|
|
|
|
|
PreFunc(); |
|
|
|
|
|
|
|
|
var hasTran = this.Context.Ado.Transaction != null; |
|
|
var hasTran = this.Context.Ado.Transaction != null; |
|
|
if (hasTran) |
|
|
if (hasTran) |
|
|
{ |
|
|
{ |
|
|
PreFunc(); |
|
|
ExecTasks(); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
this.Context.Ado.UseTran(() => |
|
|
this.Context.Ado.UseTran(() => |
|
|
{ |
|
|
{ |
|
|
PreFunc(); |
|
|
ExecTasks(); |
|
|
|
|
|
|
|
|
}, ex => throw ex); |
|
|
}, ex => throw ex); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
@ -89,10 +92,20 @@ namespace SqlSugar |
|
|
private DeleteNavTask<Root, Root> AsNav() |
|
|
private DeleteNavTask<Root, Root> AsNav() |
|
|
{ |
|
|
{ |
|
|
DeleteNavTask<Root, Root> result = new DeleteNavTask<Root, Root>(); |
|
|
DeleteNavTask<Root, Root> result = new DeleteNavTask<Root, Root>(); |
|
|
Func<DeleteNavTask<Root, Root>> func = () => PreFunc().AsNav(); |
|
|
Func<DeleteNavProvider<Root, Root>> func = () => PreFunc().AsNav(); |
|
|
result.PreFunc = func; |
|
|
result.PreFunc = func; |
|
|
result.Context = this.Context; |
|
|
result.Context = this.Context; |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
private void ExecTasks() |
|
|
|
|
|
{ |
|
|
|
|
|
var tasks=(List<Action>)this.Context.TempItems["_DeleteNavTask"]; |
|
|
|
|
|
tasks.Reverse(); |
|
|
|
|
|
foreach (var task in tasks) |
|
|
|
|
|
{ |
|
|
|
|
|
task(); |
|
|
|
|
|
} |
|
|
|
|
|
this.Context.TempItems.Remove("_DeleteNavTask"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|