mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 修复 读写分离创建 IFreeSql 时如果从库不可用导致 iis 退出的 bug;
This commit is contained in:
parent
34ba9fbf4f
commit
780b963267
@ -235,9 +235,9 @@ namespace dbcontext_01.Controllers
|
|||||||
|
|
||||||
// GET api/values/5
|
// GET api/values/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public ActionResult<string> Get(int id)
|
public ActionResult<object> Get(int id)
|
||||||
{
|
{
|
||||||
return "value";
|
return _orm.Select<Song>().Where(a => a.Id == id).First();
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST api/values
|
// POST api/values
|
||||||
|
@ -20,6 +20,9 @@ namespace dbcontext_01
|
|||||||
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document2.db;Pooling=true;Max Pool Size=10")
|
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document2.db;Pooling=true;Max Pool Size=10")
|
||||||
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
|
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
|
||||||
|
|
||||||
|
//.UseConnectionString(DataType.MySql, "Data Source=192.168.164.10;Port=33061;User ID=root;Password=123456;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=5")
|
||||||
|
//.UseSlave("Data Source=192.168.164.10;Port=33062;User ID=root;Password=123456;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=5")
|
||||||
|
|
||||||
//.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=10")
|
//.UseConnectionString(FreeSql.DataType.Oracle, "user id=user1;password=123456;data source=//127.0.0.1:1521/XE;Pooling=true;Max Pool Size=10")
|
||||||
//.UseSyncStructureToUpper(true)
|
//.UseSyncStructureToUpper(true)
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" />
|
<ProjectReference Include="..\..\Extensions\FreeSql.Extensions.LazyLoading\FreeSql.Extensions.LazyLoading.csproj" />
|
||||||
<ProjectReference Include="..\..\FreeSql.DbContext\FreeSql.DbContext.csproj" />
|
<ProjectReference Include="..\..\FreeSql.DbContext\FreeSql.DbContext.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Providers\FreeSql.Provider.MySql\FreeSql.Provider.MySql.csproj" />
|
||||||
<ProjectReference Include="..\..\Providers\FreeSql.Provider.Sqlite\FreeSql.Provider.Sqlite.csproj" />
|
<ProjectReference Include="..\..\Providers\FreeSql.Provider.Sqlite\FreeSql.Provider.Sqlite.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ namespace FreeSql.MsAccess
|
|||||||
|
|
||||||
public MsAccessConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public MsAccessConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new AccessConnectionPoolPolicy
|
var policy = new AccessConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -26,9 +28,6 @@ namespace FreeSql.MsAccess
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -19,6 +19,8 @@ namespace FreeSql.MySql
|
|||||||
|
|
||||||
public MySqlConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public MySqlConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new MySqlConnectionPoolPolicy
|
var policy = new MySqlConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -26,9 +28,6 @@ namespace FreeSql.MySql
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -23,6 +23,8 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
{
|
{
|
||||||
this.UserId = OdbcDamengConnectionPool.GetUserId(connectionString);
|
this.UserId = OdbcDamengConnectionPool.GetUserId(connectionString);
|
||||||
|
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcOracleConnectionPoolPolicy
|
var policy = new OdbcOracleConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -30,9 +32,6 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUserId(string connectionString)
|
public static string GetUserId(string connectionString)
|
||||||
|
@ -19,6 +19,8 @@ namespace FreeSql.Odbc.Default
|
|||||||
|
|
||||||
public OdbcConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public OdbcConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcConnectionPoolPolicy
|
var policy = new OdbcConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -26,9 +28,6 @@ namespace FreeSql.Odbc.Default
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -22,6 +22,8 @@ namespace FreeSql.Odbc.GBase
|
|||||||
|
|
||||||
public OdbcGBaseConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public OdbcGBaseConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcPostgreSQLConnectionPoolPolicy
|
var policy = new OdbcPostgreSQLConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -29,9 +31,6 @@ namespace FreeSql.Odbc.GBase
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -19,6 +19,8 @@ namespace FreeSql.Odbc.MySql
|
|||||||
|
|
||||||
public OdbcMySqlConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public OdbcMySqlConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcMySqlConnectionPoolPolicy
|
var policy = new OdbcMySqlConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -26,9 +28,6 @@ namespace FreeSql.Odbc.MySql
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -23,6 +23,8 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
{
|
{
|
||||||
this.UserId = OdbcOracleConnectionPool.GetUserId(connectionString);
|
this.UserId = OdbcOracleConnectionPool.GetUserId(connectionString);
|
||||||
|
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcOracleConnectionPoolPolicy
|
var policy = new OdbcOracleConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -30,9 +32,6 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUserId(string connectionString)
|
public static string GetUserId(string connectionString)
|
||||||
|
@ -20,6 +20,8 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
|
|
||||||
public OdbcPostgreSQLConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public OdbcPostgreSQLConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcPostgreSQLConnectionPoolPolicy
|
var policy = new OdbcPostgreSQLConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -27,9 +29,6 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -19,6 +19,8 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
|
|
||||||
public OdbcSqlServerConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public OdbcSqlServerConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new OdbcSqlServerConnectionPoolPolicy
|
var policy = new OdbcSqlServerConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -26,9 +28,6 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -21,6 +21,8 @@ namespace FreeSql.Oracle
|
|||||||
|
|
||||||
public OracleConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public OracleConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
this.UserId = OracleConnectionPool.GetUserId(connectionString);
|
this.UserId = OracleConnectionPool.GetUserId(connectionString);
|
||||||
|
|
||||||
var policy = new OracleConnectionPoolPolicy
|
var policy = new OracleConnectionPoolPolicy
|
||||||
@ -30,9 +32,6 @@ namespace FreeSql.Oracle
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUserId(string connectionString)
|
public static string GetUserId(string connectionString)
|
||||||
|
@ -20,6 +20,8 @@ namespace FreeSql.PostgreSQL
|
|||||||
|
|
||||||
public PostgreSQLConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public PostgreSQLConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new PostgreSQLConnectionPoolPolicy
|
var policy = new PostgreSQLConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -27,9 +29,6 @@ namespace FreeSql.PostgreSQL
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -19,6 +19,8 @@ namespace FreeSql.SqlServer
|
|||||||
|
|
||||||
public SqlServerConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public SqlServerConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
var policy = new SqlServerConnectionPoolPolicy
|
var policy = new SqlServerConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -26,9 +28,6 @@ namespace FreeSql.SqlServer
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
@ -21,6 +21,8 @@ namespace FreeSql.Sqlite
|
|||||||
|
|
||||||
public SqliteConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
public SqliteConnectionPool(string name, string connectionString, Action availableHandler, Action unavailableHandler) : base(null)
|
||||||
{
|
{
|
||||||
|
this.availableHandler = availableHandler;
|
||||||
|
this.unavailableHandler = unavailableHandler;
|
||||||
policy = new SqliteConnectionPoolPolicy
|
policy = new SqliteConnectionPoolPolicy
|
||||||
{
|
{
|
||||||
_pool = this,
|
_pool = this,
|
||||||
@ -28,9 +30,6 @@ namespace FreeSql.Sqlite
|
|||||||
};
|
};
|
||||||
this.Policy = policy;
|
this.Policy = policy;
|
||||||
policy.ConnectionString = connectionString;
|
policy.ConnectionString = connectionString;
|
||||||
|
|
||||||
this.availableHandler = availableHandler;
|
|
||||||
this.unavailableHandler = unavailableHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
public void Return(Object<DbConnection> obj, Exception exception, bool isRecreate = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user