mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	✨ support provider、Extensions Exceptions 多语言
This commit is contained in:
		@@ -24,7 +24,7 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
        public OdbcPostgreSQLOnConflictDoUpdate(IInsert<T1> insert, Expression<Func<T1, object>> columns = null)
 | 
			
		||||
        {
 | 
			
		||||
            _pgsqlInsert = insert as OdbcPostgreSQLInsert<T1>;
 | 
			
		||||
            if (_pgsqlInsert == null) throw new Exception("OnConflictDoUpdate 是 FreeSql.Provider.Odbc/PostgreSQL 特有的功能");
 | 
			
		||||
            if (_pgsqlInsert == null) throw new Exception(CoreStrings.S_Features_Unique("OnConflictDoUpdate", "Odbc/PostgreSQL"));
 | 
			
		||||
            if (_pgsqlInsert._noneParameterFlag == "c") _pgsqlInsert._noneParameterFlag = "cu";
 | 
			
		||||
 | 
			
		||||
            if (columns != null)
 | 
			
		||||
@@ -38,7 +38,7 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
            }
 | 
			
		||||
            if (_columns == null || _columns.Any() == false)
 | 
			
		||||
                _columns = _pgsqlInsert.InternalTable.Primarys;
 | 
			
		||||
            if (_columns.Any() == false) throw new Exception("OnConflictDoUpdate 功能要求实体类必须设置 IsPrimary 属性");
 | 
			
		||||
            if (_columns.Any() == false) throw new Exception(CoreStrings.S_OnConflictDoUpdate_MustIsPrimary);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected void ClearData()
 | 
			
		||||
 
 | 
			
		||||
@@ -23,12 +23,12 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (!string.IsNullOrEmpty(masterConnectionString))
 | 
			
		||||
                MasterPool = new OdbcPostgreSQLConnectionPool("主库", masterConnectionString, null, null);
 | 
			
		||||
                MasterPool = new OdbcPostgreSQLConnectionPool(CoreStrings.S_MasterDatabase, masterConnectionString, null, null);
 | 
			
		||||
            if (slaveConnectionStrings != null)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (var slaveConnectionString in slaveConnectionStrings)
 | 
			
		||||
                {
 | 
			
		||||
                    var slavePool = new OdbcPostgreSQLConnectionPool($"从库{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
 | 
			
		||||
                    var slavePool = new OdbcPostgreSQLConnectionPool($"{CoreStrings.S_SlaveDatabase}{SlavePools.Count + 1}", slaveConnectionString, () => Interlocked.Decrement(ref slaveUnavailables), () => Interlocked.Increment(ref slaveUnavailables));
 | 
			
		||||
                    SlavePools.Add(slavePool);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,7 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        internal OdbcPostgreSQLConnectionPool _pool;
 | 
			
		||||
        public string Name { get; set; } = "PostgreSQL OdbcConnection 对象池";
 | 
			
		||||
        public string Name { get; set; } = $"PostgreSQL OdbcConnection {CoreStrings.S_ObjectPool}";
 | 
			
		||||
        public int PoolSize { get; set; } = 50;
 | 
			
		||||
        public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10);
 | 
			
		||||
        public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
 | 
			
		||||
@@ -121,8 +121,8 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
            {
 | 
			
		||||
                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)
 | 
			
		||||
@@ -151,8 +151,8 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
            {
 | 
			
		||||
                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)
 | 
			
		||||
 
 | 
			
		||||
@@ -96,8 +96,8 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
            {
 | 
			
		||||
                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[] { "public", tbname[0] };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user