using FreeSql.Internal.CommonProvider; using System; using System.Data.Common; using System.Threading; namespace FreeSql.Odbc.MySql { public class OdbcMySqlProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new OdbcMySqlSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new OdbcMySqlInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new OdbcMySqlUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new OdbcMySqlDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => new OdbcMySqlInsertOrUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression); public OdbcMySqlProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new OdbcMySqlUtils(this); this.InternalCommonExpression = new OdbcMySqlExpression(this.InternalCommonUtils); this.Ado = new OdbcMySqlAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.DbFirst = new OdbcMySqlDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new OdbcMySqlCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); } ~OdbcMySqlProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; (this.Ado as AdoProvider)?.Dispose(); } } }