12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DBBackupTool.Helpers;
- internal class SqlSugarHelper
- {
- public SqlSugarClient? Client;
- public bool Open(string connectionString, SqlSugar.DbType dbType, bool isAutoConnection)
- {
- if (this.Client is not null)
- return false;
- ConnectionConfig config = new()
- {
- ConnectionString = connectionString,
- DbType = dbType,
- IsAutoCloseConnection = isAutoConnection
- };
- try
- {
- SqlSugarClient Db = new(config);
- this.Client = Db;
- }
- catch
- {
- return false;
- }
- return true;
- }
- public bool CreateTable(string database)
- {
- if (this.Client is null)
- return false;
- try
- {
- this.Client.DbMaintenance.CreateDatabase(database);
- }
- catch
- {
- return false;
- }
- return true;
- }
- }
|