using FreeSql.Internal.CommonProvider; using FreeSql.ShenTong.Curd; using System; using System.Data.Common; using System.Threading; namespace FreeSql.ShenTong { public class ShenTongProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new ShenTongSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new ShenTongInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new ShenTongUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new ShenTongDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => new ShenTongInsertOrUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression); public ShenTongProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new ShenTongUtils(this); this.InternalCommonExpression = new ShenTongExpression(this.InternalCommonUtils); this.Ado = new ShenTongAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.DbFirst = new ShenTongDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new ShenTongCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); } ~ShenTongProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; (this.Ado as AdoProvider)?.Dispose(); } } }