From 1fbac09f41c27df4c3fea262dd53f9c533b61c9e Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 28 Oct 2022 10:47:45 +0800 Subject: [PATCH] Synchronization code --- .../SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs | 4 ++++ .../Abstract/InsertableProvider/InsertableProvider.cs | 4 ++++ .../SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs | 4 ++++ .../SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs | 4 ++++ Src/Asp.NetCore2/SqlSugar/Interface/IDeleteable.cs | 1 + Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs | 1 + Src/Asp.NetCore2/SqlSugar/Interface/IUpdateable.cs | 1 + Src/Asp.NetCore2/SqlSugar/Interface/Insertable.cs | 1 + 8 files changed, 20 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index e78747bb3..2f0c50a20 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -61,6 +61,10 @@ namespace SqlSugar { return await ExecuteCommandAsync() > 0; } + public IDeleteable AsType(Type tableNameType) + { + return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName); + } public IDeleteable AS(string tableName) { if (tableName == null) return this; diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index d9ae4b6d5..ae5da01e2 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -375,6 +375,10 @@ namespace SqlSugar result.Inserable = this; return result; } + public IInsertable AsType(Type tableNameType) + { + return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName); + } public IInsertable AS(string tableName) { if (tableName == null) return this; diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 443581b8f..2fa6ff03a 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -196,6 +196,10 @@ namespace SqlSugar var entityName = typeof(T).Name; return _As(tableName, entityName); } + public ISugarQueryable AsType(Type tableNameType) + { + return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName); + } public virtual ISugarQueryable With(string withString) { if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index 8452b4e51..8393ed5f5 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -184,6 +184,10 @@ namespace SqlSugar this.IsVersionValidation = true; return this; } + public IUpdateable AsType(Type tableNameType) + { + return AS(this.Context.EntityMaintenance.GetEntityInfo(tableNameType).DbTableName); + } public IUpdateable AS(string tableName) { if (tableName == null) return this; diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IDeleteable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IDeleteable.cs index 68ef61973..249418b4c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IDeleteable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IDeleteable.cs @@ -15,6 +15,7 @@ namespace SqlSugar Task ExecuteCommandAsync(); Task ExecuteCommandHasChangeAsync(); IDeleteable AS(string tableName); + IDeleteable AsType(Type tableNameType); IDeleteable With(string lockString); IDeleteable Where(T deleteObj); IDeleteable Where(Expression> expression); diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs index 43d228b00..e203b532b 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs @@ -18,6 +18,7 @@ namespace SqlSugar ISugarQueryable Clone(); ISugarQueryable AS(string tableName); ISugarQueryable AS(string tableName); + ISugarQueryable AsType(Type tableNameType); ISugarQueryable With(string withString); //ISugarQueryable CrossQueryWithAttr(); ISugarQueryable CrossQuery(string configId); diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IUpdateable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IUpdateable.cs index 55991ff20..2c1c9393f 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IUpdateable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IUpdateable.cs @@ -21,6 +21,7 @@ namespace SqlSugar IUpdateable AS(string tableName); + IUpdateable AsType(Type tableNameType); IUpdateable With(string lockString); diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/Insertable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/Insertable.cs index e897e795e..c0d3f9d26 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/Insertable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/Insertable.cs @@ -26,6 +26,7 @@ namespace SqlSugar long ExecuteReturnBigIdentity(); Task ExecuteReturnBigIdentityAsync(); IInsertable AS(string tableName); + IInsertable AsType(Type tableNameType); IInsertable With(string lockString); IInsertable InsertColumns(Expression> columns); IInsertable InsertColumns(params string[] columns);