using FreeSql.Firebird.Curd; using FreeSql.Internal.CommonProvider; using System; using System.Data.Common; using System.Threading; namespace FreeSql.Firebird { public class FirebirdProvider : BaseDbProvider, IFreeSql { public override ISelect CreateSelectProvider(object dywhere) => new FirebirdSelect(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsert CreateInsertProvider() => new FirebirdInsert(this, this.InternalCommonUtils, this.InternalCommonExpression); public override IUpdate CreateUpdateProvider(object dywhere) => new FirebirdUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IDelete CreateDeleteProvider(object dywhere) => new FirebirdDelete(this, this.InternalCommonUtils, this.InternalCommonExpression, dywhere); public override IInsertOrUpdate CreateInsertOrUpdateProvider() => new FirebirdInsertOrUpdate(this, this.InternalCommonUtils, this.InternalCommonExpression); public FirebirdProvider(string masterConnectionString, string[] slaveConnectionString, Func connectionFactory = null) { this.InternalCommonUtils = new FirebirdUtils(this); this.InternalCommonExpression = new FirebirdExpression(this.InternalCommonUtils); this.Ado = new FirebirdAdo(this.InternalCommonUtils, masterConnectionString, slaveConnectionString, connectionFactory); this.Aop = new AopProvider(); this.DbFirst = new FirebirdDbFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); this.CodeFirst = new FirebirdCodeFirst(this, this.InternalCommonUtils, this.InternalCommonExpression); if ((this.Ado as FirebirdAdo).IsFirebird2_5) this.Aop.ConfigEntityProperty += (_, e) => { if (e.Property.PropertyType.NullableTypeOrThis() == typeof(bool)) e.ModifyResult.MapType = typeof(short); }; } ~FirebirdProvider() => this.Dispose(); int _disposeCounter; public override void Dispose() { if (Interlocked.Increment(ref _disposeCounter) != 1) return; (this.Ado as AdoProvider)?.Dispose(); } } }