using SqlSugar; namespace AStation.DAL { /// /// 数据库连接辅助类 /// internal class ConnectionFactory { private static ConnectionConfig _config = null; /// /// 创建连接对象 /// public static ConnectionConfig BuildConnection() { try { var dbName = "Db4Basic.db"; var filePath = System.IO.Path.Combine(AStation.DataFolderParas.FullPath, AStation.UserConfig.File.DataSetFolderName, dbName); if (!System.IO.File.Exists(filePath)) { throw new System.Exception($"{dbName}文件不存在!Path:{filePath}"); } _config = new ConnectionConfig() { ConnectionString = $"DataSource={filePath}", IsAutoCloseConnection = true, DbType = SqlSugar.DbType.Sqlite }; return _config; } catch (System.Exception ex) { throw ex; } } } }