From 90c4df5cc05b7cba429159e3156ef12b702cfe8c Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 3 Aug 2022 10:20:55 +0800 Subject: [PATCH] Update db.InsertNav --- .../ExecuteNavProvider/InsertNavProvider.cs | 13 +++++ .../ExecuteNavProvider/InsertNavTask.cs | 49 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs index 04d8836e5..d6caa9063 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs @@ -18,6 +18,7 @@ namespace SqlSugar public SqlSugarProvider _Context { get; set; } public NavigateType? _NavigateType { get; set; } public bool IsFirst { get; set; } + public InsertNavOptions _navOptions { get; set; } public InsertNavProvider AsNav() { @@ -29,6 +30,18 @@ namespace SqlSugar _ParentPkColumn=this._Context.EntityMaintenance.GetEntityInfo().Columns.First(it=>it.IsPrimarykey) }; } + + public InsertNavProvider ThenInclude(Expression> expression,InsertNavOptions options) where TChild : class, new() + { + _navOptions = options; + return _ThenInclude(expression); + } + public InsertNavProvider ThenInclude(Expression>> expression, InsertNavOptions options) where TChild : class, new() + { + _navOptions = options; + return _ThenInclude(expression); + } + public InsertNavProvider ThenInclude(Expression> expression) where TChild : class, new() { return _ThenInclude(expression); diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavTask.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavTask.cs index c55bbfb4b..19850223a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavTask.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavTask.cs @@ -31,6 +31,25 @@ namespace SqlSugar result.Context = this.Context; return result; } + + public InsertNavTask Include(Expression> expression,InsertNavOptions options) where TChild : class, new() + { + this.Context = insertNavProvider._Context; + InsertNavTask result = new InsertNavTask(); + Func> func = () => insertNavProvider.ThenInclude(expression, options); + result.PreFunc = func; + result.Context = this.Context; + return result; + } + public InsertNavTask Include(Expression>> expression, InsertNavOptions options) where TChild : class, new() + { + this.Context = insertNavProvider._Context; + InsertNavTask result = new InsertNavTask(); + Func> func = () => insertNavProvider.ThenInclude(expression, options); + result.PreFunc = func; + result.Context = this.Context; + return result; + } } public class InsertNavTask where T : class, new() where Root : class, new() { @@ -60,6 +79,36 @@ namespace SqlSugar { return AsNav().ThenInclude(expression); } + + + + public InsertNavTask ThenInclude(Expression> expression,InsertNavOptions options) where TChild : class, new() + { + InsertNavTask result = new InsertNavTask(); + Func> func = () => PreFunc().ThenInclude(expression,options); + result.PreFunc = func; + result.Context = this.Context; + return result; + } + public InsertNavTask ThenInclude(Expression>> expression, InsertNavOptions options) where TChild : class, new() + { + InsertNavTask result = new InsertNavTask(); + Func> func = () => PreFunc().ThenInclude(expression, options); + result.PreFunc = func; + result.Context = this.Context; + return result; + } + public InsertNavTask Include(Expression> expression, InsertNavOptions options) where TChild : class, new() + { + return AsNav().ThenInclude(expression, options); + } + public InsertNavTask Include(Expression>> expression, InsertNavOptions options) where TChild : class, new() + { + return AsNav().ThenInclude(expression, options); + } + + + public bool ExecuteCommand() { var hasTran = this.Context.Ado.Transaction != null;