mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
-
This commit is contained in:
@@ -28,8 +28,8 @@ namespace OrmTest.Demo
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.MySql,
|
||||
IsAutoCloseConnection = true,
|
||||
SlaveConnectionStrings = new List<SlaveConnectionConfig>() {
|
||||
new SlaveConnectionConfig() { HitRate=10, ConnectionString=Config.ConnectionString2 },
|
||||
SlaveConnectionConfigs = new List<SlaveConnectionConfig>() {
|
||||
new SlaveConnectionConfig() { HitRate=0, ConnectionString=Config.ConnectionString2 },
|
||||
new SlaveConnectionConfig() { HitRate=30, ConnectionString=Config.ConnectionString3 }
|
||||
}
|
||||
});
|
||||
|
@@ -28,7 +28,7 @@ namespace OrmTest.Demo
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true,
|
||||
SlaveConnectionStrings = new List<SlaveConnectionConfig>() {
|
||||
SlaveConnectionConfigs = new List<SlaveConnectionConfig>() {
|
||||
new SlaveConnectionConfig() { HitRate=10, ConnectionString=Config.ConnectionString2 },
|
||||
new SlaveConnectionConfig() { HitRate=30, ConnectionString=Config.ConnectionString3 }
|
||||
}
|
||||
|
@@ -686,7 +686,7 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Context.CurrentConnectionConfig.SlaveConnectionStrings.HasValue();
|
||||
return this.Context.CurrentConnectionConfig.SlaveConnectionConfigs.HasValue();
|
||||
}
|
||||
}
|
||||
private void SetConnectionStart(string sql)
|
||||
@@ -697,7 +697,7 @@ namespace SqlSugar
|
||||
{
|
||||
this.MasterConnection = this.Connection;
|
||||
}
|
||||
var saves = this.Context.CurrentConnectionConfig.SlaveConnectionStrings.Where(it => it.HitRate > 0).ToList();
|
||||
var saves = this.Context.CurrentConnectionConfig.SlaveConnectionConfigs.Where(it => it.HitRate > 0).ToList();
|
||||
var currentIndex = UtilRandom.GetRandomIndex(saves.ToDictionary(it => saves.ToList().IndexOf(it), it => it.HitRate));
|
||||
var currentSaveConnection = saves[currentIndex];
|
||||
this.Connection = null;
|
||||
|
@@ -32,7 +32,7 @@ namespace SqlSugar
|
||||
/// If SlaveConnectionStrings has value,ConnectionString is write operation, SlaveConnectionStrings is read operation.
|
||||
/// All operations within a transaction is ConnectionString
|
||||
/// </summary>
|
||||
public List<SlaveConnectionConfig> SlaveConnectionStrings { get; set; }
|
||||
public List<SlaveConnectionConfig> SlaveConnectionConfigs { get; set; }
|
||||
}
|
||||
|
||||
public class ConfigureExternalServices
|
||||
|
Reference in New Issue
Block a user