This commit is contained in:
28810
2019-02-25 10:12:33 +08:00
parent fb1871e558
commit 9d87c69fb2
12 changed files with 93 additions and 33 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.1.2</Version>
<Version>0.1.3</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors>
<Description>打造 .NETCore 最方便的 ORMDbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>

View File

@ -25,6 +25,10 @@ namespace FreeSql {
/// 监视数据库命令对象(执行后,用于监视执行性能)
/// </summary>
Action<DbCommand, string> AopCommandExecuted { get; set; }
/// <summary>
/// 数据库类型
/// </summary>
DataType DataType { get; }
#region
/// <summary>

View File

@ -23,15 +23,17 @@ namespace FreeSql.Internal.CommonProvider {
public ObjectPool<DbConnection> MasterPool { get; protected set; }
public List<ObjectPool<DbConnection>> SlavePools { get; } = new List<ObjectPool<DbConnection>>();
public DataType DataType { get; }
protected ICache _cache { get; set; }
protected ILogger _log { get; set; }
protected int slaveUnavailables = 0;
private object slaveLock = new object();
private Random slaveRandom = new Random();
public AdoProvider(ICache cache, ILogger log) {
public AdoProvider(ICache cache, ILogger log, DataType dataType) {
this._cache = cache;
this._log = log;
this.DataType = dataType;
}
void LoggerException(ObjectPool<DbConnection> pool, DbCommand cmd, Exception e, DateTime dt, StringBuilder logtxt, bool isThrowException = true) {

View File

@ -12,8 +12,8 @@ namespace FreeSql.MySql {
class MySqlAdo : FreeSql.Internal.CommonProvider.AdoProvider {
CommonUtils _util;
public MySqlAdo() : base(null, null) { }
public MySqlAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log) {
public MySqlAdo() : base(null, null, DataType.MySql) { }
public MySqlAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log, DataType.MySql) {
this._util = util;
MasterPool = new MySqlConnectionPool("主库", masterConnectionString, null, null);
if (slaveConnectionStrings != null) {

View File

@ -12,8 +12,8 @@ namespace FreeSql.Oracle {
class OracleAdo : FreeSql.Internal.CommonProvider.AdoProvider {
CommonUtils _util;
public OracleAdo() : base(null, null) { }
public OracleAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log) {
public OracleAdo() : base(null, null, DataType.Oracle) { }
public OracleAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log, DataType.Oracle) {
this._util = util;
MasterPool = new OracleConnectionPool("主库", masterConnectionString, null, null);
if (slaveConnectionStrings != null) {

View File

@ -14,8 +14,8 @@ namespace FreeSql.PostgreSQL {
class PostgreSQLAdo : FreeSql.Internal.CommonProvider.AdoProvider {
CommonUtils _util;
public PostgreSQLAdo() : base(null, null) { }
public PostgreSQLAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log) {
public PostgreSQLAdo() : base(null, null, DataType.PostgreSQL) { }
public PostgreSQLAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log, DataType.PostgreSQL) {
this._util = util;
MasterPool = new PostgreSQLConnectionPool("主库", masterConnectionString, null, null);
if (slaveConnectionStrings != null) {

View File

@ -12,8 +12,8 @@ namespace FreeSql.SqlServer {
class SqlServerAdo : FreeSql.Internal.CommonProvider.AdoProvider {
CommonUtils _util;
public SqlServerAdo() : base(null, null) { }
public SqlServerAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log) {
public SqlServerAdo() : base(null, null, DataType.SqlServer) { }
public SqlServerAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log, DataType.SqlServer) {
this._util = util;
MasterPool = new SqlServerConnectionPool("主库", masterConnectionString, null, null);
if (slaveConnectionStrings != null) {

View File

@ -12,8 +12,8 @@ namespace FreeSql.Sqlite {
class SqliteAdo : FreeSql.Internal.CommonProvider.AdoProvider {
CommonUtils _util;
public SqliteAdo() : base(null, null) { }
public SqliteAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log) {
public SqliteAdo() : base(null, null, DataType.Sqlite) { }
public SqliteAdo(CommonUtils util, ICache cache, ILogger log, string masterConnectionString, string[] slaveConnectionStrings) : base(cache, log, DataType.Sqlite) {
this._util = util;
MasterPool = new SqliteConnectionPool("主库", masterConnectionString, null, null);
if (slaveConnectionStrings != null) {