From 25b008c041c16a5c3b8b449777f0eebd52a72651 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 27 Jun 2022 21:08:06 +0800 Subject: [PATCH] Add insert&update&delerte nav empty api --- .../SqlServerTest/UnitTest/UCustom012.cs | 9 +++++ .../ExecuteNavProvider/DeleteNavProvider.cs | 25 ++++++++++++++ .../ExecuteNavProvider/InsertNavProvider.cs | 25 ++++++++++++++ .../ExecuteNavProvider/UpdateInsert.cs | 25 ++++++++++++++ .../SugarProvider/SqlSugarProvider.cs | 33 +++++++++++++++++++ .../SugarProvider/SqlSugarScopeProvider.cs | 24 ++++++++++++++ .../SqlSugar/Interface/ISqlSugarClient.cs | 9 +++++ Src/Asp.Net/SqlSugar/SqlSugar.csproj | 3 ++ Src/Asp.Net/SqlSugar/SqlSugarClient.cs | 27 +++++++++++++++ Src/Asp.Net/SqlSugar/SqlSugarScope.cs | 26 +++++++++++++++ 10 files changed, 206 insertions(+) create mode 100644 Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs create mode 100644 Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs create mode 100644 Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateInsert.cs diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs index 7094c69d9..776e4e529 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs @@ -105,6 +105,15 @@ namespace OrmTest .ToList(); + //功能开发中 + db.InsertNav(list3) + .ThenInclude(z1 => z1.SchoolA) + .ThenInclude(z1 => z1.RoomList) + .AsNav() + .ThenInclude(z1 => z1.Books); + + + var list3_1 = db.Queryable() .Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList()) diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs new file mode 100644 index 000000000..f0fcc4e88 --- /dev/null +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SqlSugar +{ + public class DeleteNavProvider + { + + public List Roots { get; set; } + + public DeleteNavProvider ThenInclude(Expression> expression) + { + return null; + } + + public DeleteNavProvider AsNav() + { + return null; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs new file mode 100644 index 000000000..73f6382b0 --- /dev/null +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SqlSugar +{ + public class InsertNavProvider + { + + public List Roots { get; set; } + + public InsertNavProvider ThenInclude(Expression> expression) + { + return null; + } + + public InsertNavProvider AsNav() + { + return null; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateInsert.cs b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateInsert.cs new file mode 100644 index 000000000..3e04ed68b --- /dev/null +++ b/Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateInsert.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace SqlSugar +{ + public class UpdateNavProvider + { + + public List Roots { get; set; } + + public UpdateNavProvider ThenInclude(Expression> expression) + { + return null; + } + + public UpdateNavProvider AsNav() + { + return null; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs index 86805cd77..9d180b514 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs @@ -889,6 +889,39 @@ namespace SqlSugar } #endregion + #region Nav CUD + public InsertNavProvider InsertNav(T data) + { + return InsertNav(new List() { data }); + } + public InsertNavProvider InsertNav(List datas) + { + var result = new InsertNavProvider(); + result.Roots = datas; + return result; + } + public DeleteNavProvider DeleteNav(T data) + { + return DeleteNav(new List() { data }); + } + public DeleteNavProvider DeleteNav(List datas) + { + var result = new DeleteNavProvider(); + result.Roots = datas; + return result; + } + public UpdateNavProvider UpdateNav(T data) + { + return UpdateNav(new List() { data }); + } + public UpdateNavProvider UpdateNav(List datas) + { + var result = new UpdateNavProvider(); + result.Roots = datas; + return result; + } + #endregion + #region DbFirst public virtual IDbFirst DbFirst { diff --git a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs index 41818ae63..328665b2a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs @@ -678,6 +678,30 @@ namespace SqlSugar { return ScopedContext.Saveable(saveObject); } + public InsertNavProvider InsertNav(T data) + { + return ScopedContext.InsertNav(data); + } + public InsertNavProvider InsertNav(List datas) + { + return ScopedContext.InsertNav(datas); + } + public DeleteNavProvider DeleteNav(T data) + { + return ScopedContext.DeleteNav(data); + } + public DeleteNavProvider DeleteNav(List datas) + { + return ScopedContext.DeleteNav(datas); + } + public UpdateNavProvider UpdateNav(T data) + { + return ScopedContext.UpdateNav(data); + } + public UpdateNavProvider UpdateNav(List datas) + { + return ScopedContext.UpdateNav(datas); + } #endregion } } \ No newline at end of file diff --git a/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs b/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs index ee28ad9f3..0d330cd52 100644 --- a/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs @@ -202,5 +202,14 @@ namespace SqlSugar Task ThenMapperAsync(IEnumerable list, Func action); #endregion + #region Nav CUD + InsertNavProvider InsertNav(T data); + InsertNavProvider InsertNav(List datas); + DeleteNavProvider DeleteNav(T data); + DeleteNavProvider DeleteNav(List datas); + UpdateNavProvider UpdateNav(T data); + UpdateNavProvider UpdateNav(List datas); + #endregion + } } \ No newline at end of file diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.csproj b/Src/Asp.Net/SqlSugar/SqlSugar.csproj index a9a05f7d7..a2d88c217 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.Net/SqlSugar/SqlSugar.csproj @@ -89,6 +89,9 @@ + + + diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index 705928688..5314753c4 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs @@ -153,6 +153,33 @@ namespace SqlSugar #region Queryable + #region Nav CUD + public InsertNavProvider InsertNav(T data) + { + return this.Context.InsertNav(data); + } + public InsertNavProvider InsertNav(List datas) + { + return this.Context.InsertNav(datas); + } + public DeleteNavProvider DeleteNav(T data) + { + return this.Context.DeleteNav(data); + } + public DeleteNavProvider DeleteNav(List datas) + { + return this.Context.DeleteNav(datas); + } + public UpdateNavProvider UpdateNav(T data) + { + return this.Context.UpdateNav(data); + } + public UpdateNavProvider UpdateNav(List datas) + { + return this.Context.UpdateNav(datas); + } + #endregion + #region Union public ISugarQueryable Union(List> queryables) where T : class, new() { diff --git a/Src/Asp.Net/SqlSugar/SqlSugarScope.cs b/Src/Asp.Net/SqlSugar/SqlSugarScope.cs index 1a660cf34..69721e4a3 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarScope.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarScope.cs @@ -723,5 +723,31 @@ namespace SqlSugar { return ScopedContext.DeleteableWithAttr(deleteObjs); } + + public InsertNavProvider InsertNav(T data) + { + return ScopedContext.InsertNav(data); + } + public InsertNavProvider InsertNav(List datas) + { + return ScopedContext.InsertNav(datas); + } + public DeleteNavProvider DeleteNav(T data) + { + return ScopedContext.DeleteNav(data); + } + public DeleteNavProvider DeleteNav(List datas) + { + return ScopedContext.DeleteNav(datas); + } + public UpdateNavProvider UpdateNav(T data) + { + return ScopedContext.UpdateNav(data); + } + public UpdateNavProvider UpdateNav(List datas) + { + return ScopedContext.UpdateNav(datas); + } + } }