mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
✨ support provider、Extensions Exceptions 多语言
This commit is contained in:
@ -53,7 +53,7 @@ namespace FreeSql.Odbc.MySql
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_table.Primarys.Any() == false) throw new Exception($"fsql.InsertOrUpdate + IfExistsDoNothing + MySql 要求实体类 {_table.CsName} 必须有主键");
|
||||
if (_table.Primarys.Any() == false) throw new Exception(CoreStrings.Entity_Must_Primary_Key("fsql.InsertOrUpdate + IfExistsDoNothing + MySql ", _table.CsName));
|
||||
sql = insert.ToSqlValuesOrSelectUnionAllExtension101(false, (rowd, idx, sb) =>
|
||||
sb.Append(" \r\n FROM dual WHERE NOT EXISTS(").Append(
|
||||
_orm.Select<T1>()
|
||||
|
@ -17,7 +17,7 @@ namespace FreeSql.Odbc.MySql
|
||||
public OdbcMySqlOnDuplicateKeyUpdate(IInsert<T1> insert)
|
||||
{
|
||||
_mysqlInsert = insert as OdbcMySqlInsert<T1>;
|
||||
if (_mysqlInsert == null) throw new Exception("OnDuplicateKeyUpdate 是 FreeSql.Provider.Odbc/MySql 特有的功能");
|
||||
if (_mysqlInsert == null) throw new Exception(CoreStrings.S_Features_Unique("OnDuplicateKeyUpdate", "Odbc/MySql"));
|
||||
if (_mysqlInsert._noneParameterFlag == "c") _mysqlInsert._noneParameterFlag = "cu";
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,12 @@ namespace FreeSql.Odbc.MySql
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(masterConnectionString))
|
||||
MasterPool = new OdbcMySqlConnectionPool("主库", masterConnectionString, null, null);
|
||||
MasterPool = new OdbcMySqlConnectionPool(CoreStrings.S_MasterDatabase, masterConnectionString, null, null);
|
||||
if (slaveConnectionStrings != null)
|
||||
{
|
||||
foreach (var slaveConnectionString in slaveConnectionStrings)
|
||||
{
|
||||
var slavePool = new OdbcMySqlConnectionPool($"从库{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
|
||||
var slavePool = new OdbcMySqlConnectionPool($"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
|
||||
SlavePools.Add(slavePool);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace FreeSql.Odbc.MySql
|
||||
{
|
||||
|
||||
internal OdbcMySqlConnectionPool _pool;
|
||||
public string Name { get; set; } = "MySql OdbcConnection 对象池";
|
||||
public string Name { get; set; } = $"MySql OdbcConnection {CoreStrings.S_ObjectPool}";
|
||||
public int PoolSize { get; set; } = 100;
|
||||
public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10);
|
||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||
@ -120,8 +120,8 @@ namespace FreeSql.Odbc.MySql
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||
_pool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
||||
@ -150,8 +150,8 @@ namespace FreeSql.Odbc.MySql
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
_pool.SetUnavailable(new Exception("连接字符串错误"), obj.LastGetTimeCopy);
|
||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||
_pool.SetUnavailable(new Exception(CoreStrings.S_ConnectionStringError), obj.LastGetTimeCopy);
|
||||
throw new Exception(CoreStrings.S_ConnectionStringError_Check(this.Name));
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
||||
|
@ -90,8 +90,8 @@ namespace FreeSql.Odbc.MySql
|
||||
{
|
||||
if (sb.Length > 0) sb.Append("\r\n");
|
||||
var tb = _commonUtils.GetTableByEntity(obj.entityType);
|
||||
if (tb == null) throw new Exception($"类型 {obj.entityType.FullName} 不可迁移");
|
||||
if (tb.Columns.Any() == false) throw new Exception($"类型 {obj.entityType.FullName} 不可迁移,可迁移属性0个");
|
||||
if (tb == null) throw new Exception(CoreStrings.S_Type_IsNot_Migrable(obj.entityType.FullName));
|
||||
if (tb.Columns.Any() == false) throw new Exception(CoreStrings.S_Type_IsNot_Migrable_0Attributes(obj.entityType.FullName));
|
||||
var tbname = _commonUtils.SplitTableName(tb.DbName);
|
||||
if (tbname?.Length == 1) tbname = new[] { database, tbname[0] };
|
||||
|
||||
|
Reference in New Issue
Block a user