From a82c1a96947ea72a7b88c1b4043ce023a0efe9bd Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 22 Oct 2022 13:26:38 +0800 Subject: [PATCH] Adding method overload --- .../Abstract/DbMaintenanceProvider/Methods.cs | 26 +++++++++++++++++++ .../SqlSugar/Interface/IDbMaintenance.cs | 3 +++ 2 files changed, 29 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs index 298b441f3..2ebf62065 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs @@ -261,6 +261,15 @@ namespace SqlSugar } return true; } + public virtual bool DropTable(Type[] tableEnittyTypes) + { + foreach (var item in tableEnittyTypes) + { + var tableName = this.Context.EntityMaintenance.GetTableName(item); + DropTable(tableName); + } + return true; + } public virtual bool DropTable() { var tableName= this.Context.EntityMaintenance.GetTableName(); @@ -342,6 +351,23 @@ namespace SqlSugar this.Context.Ado.ExecuteCommand(string.Format(this.TruncateTableSql, tableName)); return true; } + public bool TruncateTable(params string[] tableNames) + { + foreach (var item in tableNames) + { + TruncateTable(item); + } + return true; + } + public bool TruncateTable(params Type[] tableEnittyTypes) + { + foreach (var item in tableEnittyTypes) + { + var name = this.Context.EntityMaintenance.GetTableName(item); + TruncateTable(name); + } + return true; + } public virtual bool BackupDataBase(string databaseName, string fullFileName) { var directory = FileHelper.GetDirectoryFromFilePath(fullFileName); diff --git a/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs b/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs index e319d971a..299339276 100644 --- a/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs +++ b/Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs @@ -33,11 +33,14 @@ namespace SqlSugar bool CreateIndex(string tableName, string[] columnNames, string IndexName, bool isUnique = false); bool DropTable(string tableName); bool DropTable(params string[] tableName); + bool DropTable(params Type[] tableEntityTypes); bool DropTable(); bool DropTable(); bool DropTable(); bool DropTable(); bool TruncateTable(string tableName); + bool TruncateTable(params string[] tableName); + bool TruncateTable(params Type[] tableEntityType); bool TruncateTable(); bool TruncateTable(); bool TruncateTable();