using FreeSql.Dameng.Curd; using FreeSql.Internal.CommonProvider; using System; using System.Data.Common; using System.Threading; namespace FreeSql.Dameng { public class DamengProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new DamengSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new DamengInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new DamengUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new DamengDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => new DamengInsertOrUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression); public DamengProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new DamengUtils(this); this.InternalCommonExpression = new DamengExpression(this.InternalCommonUtils); this.Ado = new DamengAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.DbFirst = new DamengDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new DamengCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); } ~DamengProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; (this.Ado as AdoProvider)?.Dispose(); } } }