using FreeSql.Internal.CommonProvider; using System; using System.Data.Common; using System.Threading; namespace FreeSql.Odbc.KingbaseES { public class OdbcKingbaseESProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new OdbcKingbaseESSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new OdbcKingbaseESInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new OdbcKingbaseESUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new OdbcKingbaseESDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => new OdbcKingbaseESInsertOrUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression); public OdbcKingbaseESProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new OdbcKingbaseESUtils(this); this.InternalCommonExpression = new OdbcKingbaseESExpression(this.InternalCommonUtils); this.Ado = new OdbcKingbaseESAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.DbFirst = new OdbcKingbaseESDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new OdbcKingbaseESCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); } ~OdbcKingbaseESProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; (this.Ado as AdoProvider)?.Dispose(); } } }