This commit is contained in:
sunkaixuan
2017-10-24 17:00:21 +08:00
parent f0fa2c5a14
commit 5f1166a404
4 changed files with 6 additions and 6 deletions

View File

@@ -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 }
}
});

View File

@@ -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 }
}

View File

@@ -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;

View File

@@ -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