mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 01:05:27 +08:00 
			
		
		
		
	- 读写分离部门代码处理
This commit is contained in:
		@@ -110,6 +110,13 @@
 | 
			
		||||
            清空状态数据
 | 
			
		||||
            </summary>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
 | 
			
		||||
            <summary>
 | 
			
		||||
            根据 lambda 条件删除数据
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="predicate"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.DbSet`1.Add(`0)">
 | 
			
		||||
            <summary>
 | 
			
		||||
            添加
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.MySql.Curd
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -218,7 +218,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
 | 
			
		||||
 | 
			
		||||
                    if (istmpatler == false)
 | 
			
		||||
                    {
 | 
			
		||||
                        var existsPrimary = ExecuteScalar(tbname[0], _commonUtils.FormatSql("select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
 | 
			
		||||
                        var existsPrimary = ExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
 | 
			
		||||
                        foreach (var tbcol in tb.ColumnsByPosition)
 | 
			
		||||
                        {
 | 
			
		||||
                            var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1;
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@ namespace FreeSql.Odbc.Default
 | 
			
		||||
                    conn = poolConn.Value;
 | 
			
		||||
                }
 | 
			
		||||
                _orm.Ado.ExecuteNonQuery(conn, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
                ret = long.TryParse(string.Concat(_orm.Ado.ExecuteScalar(conn, _transaction, CommandType.Text, _utils.Adapter.InsertAfterGetIdentitySql)), out var trylng) ? trylng : 0;
 | 
			
		||||
                ret = long.TryParse(string.Concat(_orm.Ado.ExecuteScalar(conn, _transaction, CommandType.Text, $" {_utils.Adapter.InsertAfterGetIdentitySql}")), out var trylng) ? trylng : 0;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
@@ -89,7 +89,7 @@ namespace FreeSql.Odbc.Default
 | 
			
		||||
                    conn = poolConn.Value;
 | 
			
		||||
                }
 | 
			
		||||
                await _orm.Ado.ExecuteNonQueryAsync(conn, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
                ret = long.TryParse(string.Concat(await _orm.Ado.ExecuteScalarAsync(conn, _transaction, CommandType.Text, _utils.Adapter.InsertAfterGetIdentitySql)), out var trylng) ? trylng : 0;
 | 
			
		||||
                ret = long.TryParse(string.Concat(await _orm.Ado.ExecuteScalarAsync(conn, _transaction, CommandType.Text, $" {_utils.Adapter.InsertAfterGetIdentitySql}")), out var trylng) ? trylng : 0;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.Odbc.Default
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ namespace FreeSql.Odbc.MySql
 | 
			
		||||
                    conn = poolConn.Value;
 | 
			
		||||
                }
 | 
			
		||||
                _orm.Ado.ExecuteNonQuery(conn, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
                ret = long.TryParse(string.Concat(_orm.Ado.ExecuteScalar(conn, _transaction, CommandType.Text, "SELECT LAST_INSERT_ID()")), out var trylng) ? trylng : 0;
 | 
			
		||||
                ret = long.TryParse(string.Concat(_orm.Ado.ExecuteScalar(conn, _transaction, CommandType.Text, " SELECT LAST_INSERT_ID()")), out var trylng) ? trylng : 0;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
@@ -122,7 +122,7 @@ namespace FreeSql.Odbc.MySql
 | 
			
		||||
                    conn = poolConn.Value;
 | 
			
		||||
                }
 | 
			
		||||
                await _orm.Ado.ExecuteNonQueryAsync(conn, _transaction, CommandType.Text, sql, _params);
 | 
			
		||||
                ret = long.TryParse(string.Concat(await _orm.Ado.ExecuteScalarAsync(conn, _transaction, CommandType.Text, "SELECT LAST_INSERT_ID()")), out var trylng) ? trylng : 0;
 | 
			
		||||
                ret = long.TryParse(string.Concat(await _orm.Ado.ExecuteScalarAsync(conn, _transaction, CommandType.Text, " SELECT LAST_INSERT_ID()")), out var trylng) ? trylng : 0;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.Odbc.MySql
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -207,7 +207,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
 | 
			
		||||
 | 
			
		||||
                    if (istmpatler == false)
 | 
			
		||||
                    {
 | 
			
		||||
                        var existsPrimary = ExecuteScalar(tbname[0], _commonUtils.FormatSql("select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
 | 
			
		||||
                        var existsPrimary = ExecuteScalar(tbname[0], _commonUtils.FormatSql(" select 1 from information_schema.key_column_usage where table_schema={0} and table_name={1} and constraint_name = 'PRIMARY' limit 1", tbname));
 | 
			
		||||
                        foreach (var tbcol in tb.ColumnsByPosition)
 | 
			
		||||
                        {
 | 
			
		||||
                            var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1;
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.Odbc.Oracle
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
@@ -109,13 +109,13 @@ namespace FreeSql.Odbc.Oracle
 | 
			
		||||
                if (string.IsNullOrEmpty(_orderby))
 | 
			
		||||
                {
 | 
			
		||||
                    if (_skip > 0)
 | 
			
		||||
                        sb.Insert(0, "SELECT t.* FROM (").Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                        sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (_skip > 0 && _limit > 0) sb.Insert(0, "SELECT t.* FROM (SELECT rt.*, ROWNUM AS \"__rownum__\" FROM (").Append(") rt WHERE ROWNUM < ").Append(_skip + _limit + 1).Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                    else if (_skip > 0) sb.Insert(0, "SELECT t.* FROM (").Append(") t WHERE ROWNUM > ").Append(_skip);
 | 
			
		||||
                    else if (_limit > 0) sb.Insert(0, "SELECT t.* FROM (").Append(") t WHERE ROWNUM < ").Append(_limit + 1);
 | 
			
		||||
                    if (_skip > 0 && _limit > 0) sb.Insert(0, $"{_select} t.* FROM (SELECT rt.*, ROWNUM AS \"__rownum__\" FROM (").Append(") rt WHERE ROWNUM < ").Append(_skip + _limit + 1).Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                    else if (_skip > 0) sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE ROWNUM > ").Append(_skip);
 | 
			
		||||
                    else if (_limit > 0) sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE ROWNUM < ").Append(_limit + 1);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                sbnav.Clear();
 | 
			
		||||
 
 | 
			
		||||
@@ -287,7 +287,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
 | 
			
		||||
                    sb.Append(sbalter);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@"select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
			
		||||
                if (string.IsNullOrEmpty(oldpk) == false)
 | 
			
		||||
                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -174,7 +174,7 @@ namespace FreeSql.Odbc.Oracle
 | 
			
		||||
 | 
			
		||||
            if (database == null || database.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                var userUsers = _orm.Ado.ExecuteScalar("select username from user_users")?.ToString();
 | 
			
		||||
                var userUsers = _orm.Ado.ExecuteScalar(" select username from user_users")?.ToString();
 | 
			
		||||
                if (string.IsNullOrEmpty(userUsers)) return loc1;
 | 
			
		||||
                database = new[] { userUsers };
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.Odbc.PostgreSQL
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -296,7 +296,7 @@ where ns.nspname in ({0}) and d.relname in ({1}) and a.indisprimary = 'f'", tbol
 | 
			
		||||
                    sb.Append(sbalter);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@"select pg_constraint.conname as pk_name from pg_constraint
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select pg_constraint.conname as pk_name from pg_constraint
 | 
			
		||||
inner join pg_class on pg_constraint.conrelid = pg_class.oid
 | 
			
		||||
inner join pg_namespace on pg_namespace.oid = pg_class.relnamespace
 | 
			
		||||
where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contype='p'
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
@@ -147,7 +147,7 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
                
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -253,8 +253,8 @@ from sys.columns", loc8.ToString().Replace("a.table_name", "a.object_id"));
 | 
			
		||||
                {
 | 
			
		||||
                    sql += "union all" +
 | 
			
		||||
                    string.Format(tsql_place.Replace(
 | 
			
		||||
                        "select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.column_id",
 | 
			
		||||
                        "select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.parameter_id"), @"
 | 
			
		||||
                        " select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.column_id",
 | 
			
		||||
                        " select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.parameter_id"), @"
 | 
			
		||||
,cast(0 as bit) 'IsNullable'
 | 
			
		||||
,a.is_output 'IsIdentity'
 | 
			
		||||
from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"));
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.Oracle.Curd
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
@@ -109,13 +109,13 @@ namespace FreeSql.Oracle.Curd
 | 
			
		||||
                if (string.IsNullOrEmpty(_orderby))
 | 
			
		||||
                {
 | 
			
		||||
                    if (_skip > 0)
 | 
			
		||||
                        sb.Insert(0, "SELECT t.* FROM (").Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                        sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (_skip > 0 && _limit > 0) sb.Insert(0, "SELECT t.* FROM (SELECT rt.*, ROWNUM AS \"__rownum__\" FROM (").Append(") rt WHERE ROWNUM < ").Append(_skip + _limit + 1).Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                    else if (_skip > 0) sb.Insert(0, "SELECT t.* FROM (").Append(") t WHERE ROWNUM > ").Append(_skip);
 | 
			
		||||
                    else if (_limit > 0) sb.Insert(0, "SELECT t.* FROM (").Append(") t WHERE ROWNUM < ").Append(_limit + 1);
 | 
			
		||||
                    if (_skip > 0 && _limit > 0) sb.Insert(0, $"{_select} t.* FROM (SELECT rt.*, ROWNUM AS \"__rownum__\" FROM (").Append(") rt WHERE ROWNUM < ").Append(_skip + _limit + 1).Append(") t WHERE t.\"__rownum__\" > ").Append(_skip);
 | 
			
		||||
                    else if (_skip > 0) sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE ROWNUM > ").Append(_skip);
 | 
			
		||||
                    else if (_limit > 0) sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE ROWNUM < ").Append(_limit + 1);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                sbnav.Clear();
 | 
			
		||||
 
 | 
			
		||||
@@ -288,7 +288,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
 | 
			
		||||
                    sb.Append(sbalter);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@"select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select constraint_name from user_constraints where owner={0} and table_name={1} and constraint_type='P'", tbname))?.ToString();
 | 
			
		||||
                if (string.IsNullOrEmpty(oldpk) == false)
 | 
			
		||||
                    sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -174,7 +174,7 @@ namespace FreeSql.Oracle
 | 
			
		||||
 | 
			
		||||
            if (database == null || database.Any() == false)
 | 
			
		||||
            {
 | 
			
		||||
                var userUsers = _orm.Ado.ExecuteScalar("select username from user_users")?.ToString();
 | 
			
		||||
                var userUsers = _orm.Ado.ExecuteScalar(" select username from user_users")?.ToString();
 | 
			
		||||
                if (string.IsNullOrEmpty(userUsers)) return loc1;
 | 
			
		||||
                database = new[] { userUsers };
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.PostgreSQL.Curd
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -334,7 +334,7 @@ where ns.nspname in ({0}) and d.relname in ({1}) and a.indisprimary = 'f'", tbol
 | 
			
		||||
                    sb.Append(sbalter);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@"select pg_constraint.conname as pk_name from pg_constraint
 | 
			
		||||
                var oldpk = _orm.Ado.ExecuteScalar(CommandType.Text, _commonUtils.FormatSql(@" select pg_constraint.conname as pk_name from pg_constraint
 | 
			
		||||
inner join pg_class on pg_constraint.conrelid = pg_class.oid
 | 
			
		||||
inner join pg_namespace on pg_namespace.oid = pg_class.relnamespace
 | 
			
		||||
where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contype='p'
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ namespace FreeSql.SqlServer.Curd
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
@@ -147,7 +147,7 @@ namespace FreeSql.SqlServer.Curd
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
                
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -256,8 +256,8 @@ from sys.columns", loc8.ToString().Replace("a.table_name", "a.object_id"));
 | 
			
		||||
                {
 | 
			
		||||
                    sql += "union all" +
 | 
			
		||||
                    string.Format(tsql_place.Replace(
 | 
			
		||||
                        "select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.column_id",
 | 
			
		||||
                        "select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.parameter_id"), @"
 | 
			
		||||
                        " select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.column_id",
 | 
			
		||||
                        " select value from sys.extended_properties where major_id = a.object_id AND minor_id = a.parameter_id"), @"
 | 
			
		||||
,cast(0 as bit) 'IsNullable'
 | 
			
		||||
,a.is_output 'IsIdentity'
 | 
			
		||||
from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"));
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace FreeSql.Sqlite.Curd
 | 
			
		||||
            for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
 | 
			
		||||
            {
 | 
			
		||||
                if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append("select * from (");
 | 
			
		||||
                if (tbUnionsGt0) sb.Append(_select).Append(" * from (");
 | 
			
		||||
                var tbUnion = tbUnions[tbUnionsIdx];
 | 
			
		||||
 | 
			
		||||
                var sbnav = new StringBuilder();
 | 
			
		||||
 
 | 
			
		||||
@@ -211,7 +211,7 @@ namespace FreeSql.Sqlite
 | 
			
		||||
                    {
 | 
			
		||||
                        if (string.Concat(dbIndex[3]) == "pk") continue;
 | 
			
		||||
                        var dbIndexesColumns = _orm.Ado.ExecuteArray(CommandType.Text, $"PRAGMA {_commonUtils.QuoteSqlName(tbtmp[0])}.INDEX_INFO({dbIndex[1]})");
 | 
			
		||||
                        var dbIndexesSql = string.Concat(_orm.Ado.ExecuteScalar(CommandType.Text, $"SELECT sql FROM sqlite_master WHERE name = '{dbIndex[1]}'"));
 | 
			
		||||
                        var dbIndexesSql = string.Concat(_orm.Ado.ExecuteScalar(CommandType.Text, $" SELECT sql FROM sqlite_master WHERE name = '{dbIndex[1]}'"));
 | 
			
		||||
                        foreach (var dbcolumn in dbIndexesColumns)
 | 
			
		||||
                        {
 | 
			
		||||
                            var dbcolumnName = string.Concat(dbcolumn[2]);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user