using FreeSql.Internal.CommonProvider; using System; using System.Data.Common; using System.Threading; namespace FreeSql.Custom.Oracle { public class CustomOracleProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new CustomOracleSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new CustomOracleInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new CustomOracleUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new CustomOracleDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => new CustomOracleInsertOrUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression); public CustomOracleProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new CustomOracleUtils(this); this.InternalCommonExpression = new CustomOracleExpression(this.InternalCommonUtils); this.Ado = new CustomOracleAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.DbFirst = new CustomOracleDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new CustomOracleCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); //this.Aop.AuditValue += new EventHandler((_, e) => //{ // if (e.Value == null && e.Column.Attribute.IsPrimary == false && e.Column.Attribute.IsIdentity == false) // e.Value = Utils.GetDataReaderValue(e.Property.PropertyType.NullableTypeOrThis(), e.Column.Attribute.DbDefautValue); //}); } ~CustomOracleProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; try { (this.Ado as AdoProvider)?.Dispose(); } finally { FreeSqlCustomAdapterGlobalExtensions._dicCustomAdater.TryRemove(Ado.Identifier, out var tryada); FreeSqlCustomAdapterGlobalExtensions._dicDbProviderFactory.TryRemove(Ado.Identifier, out var trydbpf); } } } }