using FreeSql.Internal.CommonProvider; using FreeSql.MsAccess.Curd; using System; using System.Data.Common; using System.Threading; namespace FreeSql.MsAccess { public class MsAccessProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new MsAccessSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new MsAccessInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new MsAccessUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new MsAccessDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => throw new NotImplementedException(); public override IDbFirst DbFirst => throw new NotImplementedException($"FreeSql.Provider.MsAccess {CoreStrings.S_Not_Implemented_Feature}"); public MsAccessProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new MsAccessUtils(this); this.InternalCommonExpression = new MsAccessExpression(this.InternalCommonUtils); this.Ado = new MsAccessAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.CodeFirst = new MsAccessCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); } ~MsAccessProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; (this.Ado as AdoProvider)?.Dispose(); } } }