diff --git a/Repository/BaseRepository/Implement/BaseRepository.cs b/Repository/BaseRepository/Implement/BaseRepository.cs
index e0b50cd..0de7f78 100644
--- a/Repository/BaseRepository/Implement/BaseRepository.cs
+++ b/Repository/BaseRepository/Implement/BaseRepository.cs
@@ -888,5 +888,41 @@ namespace Repository.BaseRepository.Implement
}
#endregion AddOneReturnId
+
+ #region TruncateTable (清空資料表)
+ ///
+ /// 清空資料表資料
+ /// TRUNCATE TABLE {tableName}
+ ///
+ ///
+ ///
+ public virtual async Task TruncateTable(string table_name)
+ {
+ using (IDbConnection conn = GetDbConnection())
+ {
+ conn.Open();
+ using (var trans = conn.BeginTransaction())
+ {
+ try
+ {
+ var sql = $"TRUNCATE TABLE {table_name}";
+ await conn.ExecuteAsync(sql, null, trans);
+
+ trans.Commit();
+ }
+ catch (Exception exception)
+ {
+ trans.Rollback();
+ throw exception;
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+ }
+ #endregion TruncateTable
+
}
}
diff --git a/Repository/BaseRepository/Interface/IBaseRepository.cs b/Repository/BaseRepository/Interface/IBaseRepository.cs
index c4ad4df..1c041a0 100644
--- a/Repository/BaseRepository/Interface/IBaseRepository.cs
+++ b/Repository/BaseRepository/Interface/IBaseRepository.cs
@@ -181,5 +181,12 @@ namespace Repository.BaseRepository.Interface
///
///
Task AddOneByCustomTableReturnId(Dictionary dict, string Table_name, bool returnId = true);
+ ///
+ /// 清空table資料
+ ///
+ /// 資料表名稱
+ ///
+ ///
+ Task TruncateTable(string table_name);
}
}