/// <summary> /// 从配置文件中读取连接字符串并创建 MySql 数据库访问器 /// </summary> /// <param name="name">连接字符串配置名称</param> /// <param name="configuration">MySql 配置</param> /// <returns>MySql 数据库访问器</returns> public static MySqlDbExecutor FromConfiguration( string name, MySqlDbConfiguration configuration = null ) { var setting = ConfigurationManager.ConnectionStrings[name]; if ( setting == null ) throw new InvalidOperationException(); return Connect( setting.ConnectionString, configuration ); }
/// <summary> /// 通过指定的用户名和密码登陆 MySql 数据库,以创建 MySql 数据库访问器 /// </summary> /// <param name="server">数据库服务器地址</param> /// <param name="database">数据库名称</param> /// <param name="userID">登录数据库的用户名</param> /// <param name="password">登录数据库的密码</param> /// <param name="pooling">是否启用连接池(默认启用)</param> /// <param name="configuration">MySql 数据库配置</param> /// <returns>MySql 数据库访问器</returns> public static MySqlDbExecutor Connect( string server, string database, string userID, string password, bool pooling = true, MySqlDbConfiguration configuration = null ) { var builder = new MySqlConnectionStringBuilder() { Server = server, Database = database, IntegratedSecurity = false, UserID = userID, Password = password, Pooling = pooling }; return Connect( builder.ConnectionString, configuration ); }
public MySqlDbExecutor(string connectionString, MySqlDbConfiguration configuration) : base(configuration) { if (connectionString == null) { throw new ArgumentNullException("connectionString"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } ConnectionString = connectionString; Configuration = configuration; }
/// <summary> /// 通过指定的连接字符串构建器创建 MySql 数据库访问器 /// </summary> /// <param name="builder">连接字符串构建器</param> /// <param name="configuration">MySql 配置</param> /// <returns>MySql 数据库访问器</returns> public static MySqlDbExecutor Connect( MySqlConnectionStringBuilder builder, MySqlDbConfiguration configuration = null ) { return Connect( builder.ConnectionString, configuration ); }
/// <summary> /// 通过指定的连接字符串并创建 MySql 数据库访问器 /// </summary> /// <param name="connectionString">连接字符串</param> /// <param name="configuration">MySql 配置</param> /// <returns>MySql 数据库访问器</returns> public static MySqlDbExecutor Connect( string connectionString, MySqlDbConfiguration configuration = null ) { return new MySqlDbExecutor( connectionString, configuration ?? DefaultConfiguration ); }
static MySqlDb() { DefaultConfiguration = new MySqlDbConfiguration(); }
/// <summary> /// 通过集成身份验证登陆 MySql 数据库,以创建 MySql 数据库访问器 /// </summary> /// <param name="dataSource">数据库服务器地址</param> /// <param name="port">数据库服务器端口</param> /// <param name="database">数据库名称</param> /// <param name="pooling">是否启用连接池(默认启用)</param> /// <param name="configuration">MySql 数据库配置</param> /// <returns>MySql 数据库访问器</returns> public static MySqlDbExecutor Connect( string server, uint port, string database, bool pooling = true, MySqlDbConfiguration configuration = null ) { var builder = new MySqlConnectionStringBuilder() { Server = server, Port = port, Database = database, IntegratedSecurity = true, Pooling = pooling }; return Connect( builder.ConnectionString, configuration ); }
public MySqlDbExecutorWithTransaction(MySqlDbTransactionContext transaction, MySqlDbConfiguration configuration) : base(transaction.Connection.ConnectionString, configuration) { _transaction = transaction; }
internal MySqlDbTransactionContext(string connectionString, MySqlDbConfiguration configuration) { Connection = new MySqlConnection(connectionString); _executor = new MySqlDbExecutorWithTransaction(this, configuration); }