- 读写分离部门代码处理

This commit is contained in:
28810 2019-12-09 15:29:50 +08:00
parent a33cad02cc
commit 9bae834386
24 changed files with 44 additions and 37 deletions

View File

@ -110,6 +110,13 @@
清空状态数据 清空状态数据
</summary> </summary>
</member> </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)"> <member name="M:FreeSql.DbSet`1.Add(`0)">
<summary> <summary>
添加 添加

View File

@ -26,7 +26,7 @@ namespace FreeSql.MySql.Curd
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -218,7 +218,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
if (istmpatler == false) 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) foreach (var tbcol in tb.ColumnsByPosition)
{ {
var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1; var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1;

View File

@ -43,7 +43,7 @@ namespace FreeSql.Odbc.Default
conn = poolConn.Value; conn = poolConn.Value;
} }
_orm.Ado.ExecuteNonQuery(conn, _transaction, CommandType.Text, sql, _params); _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) catch (Exception ex)
{ {
@ -89,7 +89,7 @@ namespace FreeSql.Odbc.Default
conn = poolConn.Value; conn = poolConn.Value;
} }
await _orm.Ado.ExecuteNonQueryAsync(conn, _transaction, CommandType.Text, sql, _params); 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) catch (Exception ex)
{ {

View File

@ -26,7 +26,7 @@ namespace FreeSql.Odbc.Default
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -42,7 +42,7 @@ namespace FreeSql.Odbc.MySql
conn = poolConn.Value; conn = poolConn.Value;
} }
_orm.Ado.ExecuteNonQuery(conn, _transaction, CommandType.Text, sql, _params); _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) catch (Exception ex)
{ {
@ -122,7 +122,7 @@ namespace FreeSql.Odbc.MySql
conn = poolConn.Value; conn = poolConn.Value;
} }
await _orm.Ado.ExecuteNonQueryAsync(conn, _transaction, CommandType.Text, sql, _params); 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) catch (Exception ex)
{ {

View File

@ -26,7 +26,7 @@ namespace FreeSql.Odbc.MySql
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -207,7 +207,7 @@ where a.table_schema in ({0}) and a.table_name in ({1})", tboldname ?? tbname);
if (istmpatler == false) 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) foreach (var tbcol in tb.ColumnsByPosition)
{ {
var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1; var isIdentityChanged = tbcol.Attribute.IsIdentity == true && tbcol.Attribute.DbType.IndexOf("AUTO_INCREMENT", StringComparison.CurrentCultureIgnoreCase) == -1;

View File

@ -26,7 +26,7 @@ namespace FreeSql.Odbc.Oracle
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();
@ -109,13 +109,13 @@ namespace FreeSql.Odbc.Oracle
if (string.IsNullOrEmpty(_orderby)) if (string.IsNullOrEmpty(_orderby))
{ {
if (_skip > 0) 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 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); 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 (_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); else if (_limit > 0) sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE ROWNUM < ").Append(_limit + 1);
} }
sbnav.Clear(); sbnav.Clear();

View File

@ -287,7 +287,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
sb.Append(sbalter); sb.Append(sbalter);
continue; 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) 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"); sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");

View File

@ -174,7 +174,7 @@ namespace FreeSql.Odbc.Oracle
if (database == null || database.Any() == false) 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; if (string.IsNullOrEmpty(userUsers)) return loc1;
database = new[] { userUsers }; database = new[] { userUsers };
} }

View File

@ -26,7 +26,7 @@ namespace FreeSql.Odbc.PostgreSQL
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -296,7 +296,7 @@ where ns.nspname in ({0}) and d.relname in ({1}) and a.indisprimary = 'f'", tbol
sb.Append(sbalter); sb.Append(sbalter);
continue; 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_class on pg_constraint.conrelid = pg_class.oid
inner join pg_namespace on pg_namespace.oid = pg_class.relnamespace 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' where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contype='p'

View File

@ -32,7 +32,7 @@ namespace FreeSql.Odbc.SqlServer
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();
@ -147,7 +147,7 @@ namespace FreeSql.Odbc.SqlServer
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -253,8 +253,8 @@ from sys.columns", loc8.ToString().Replace("a.table_name", "a.object_id"));
{ {
sql += "union all" + sql += "union all" +
string.Format(tsql_place.Replace( 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.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.parameter_id"), @"
,cast(0 as bit) 'IsNullable' ,cast(0 as bit) 'IsNullable'
,a.is_output 'IsIdentity' ,a.is_output 'IsIdentity'
from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id")); from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"));

View File

@ -26,7 +26,7 @@ namespace FreeSql.Oracle.Curd
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();
@ -109,13 +109,13 @@ namespace FreeSql.Oracle.Curd
if (string.IsNullOrEmpty(_orderby)) if (string.IsNullOrEmpty(_orderby))
{ {
if (_skip > 0) 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 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); 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 (_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); else if (_limit > 0) sb.Insert(0, $"{_select} t.* FROM (").Append(") t WHERE ROWNUM < ").Append(_limit + 1);
} }
sbnav.Clear(); sbnav.Clear();

View File

@ -288,7 +288,7 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
sb.Append(sbalter); sb.Append(sbalter);
continue; 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) 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"); sb.Append("execute immediate 'ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" DROP CONSTRAINT ").Append(oldpk).Append("';\r\n");

View File

@ -174,7 +174,7 @@ namespace FreeSql.Oracle
if (database == null || database.Any() == false) 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; if (string.IsNullOrEmpty(userUsers)) return loc1;
database = new[] { userUsers }; database = new[] { userUsers };
} }

View File

@ -26,7 +26,7 @@ namespace FreeSql.PostgreSQL.Curd
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -334,7 +334,7 @@ where ns.nspname in ({0}) and d.relname in ({1}) and a.indisprimary = 'f'", tbol
sb.Append(sbalter); sb.Append(sbalter);
continue; 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_class on pg_constraint.conrelid = pg_class.oid
inner join pg_namespace on pg_namespace.oid = pg_class.relnamespace 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' where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contype='p'

View File

@ -32,7 +32,7 @@ namespace FreeSql.SqlServer.Curd
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();
@ -147,7 +147,7 @@ namespace FreeSql.SqlServer.Curd
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -256,8 +256,8 @@ from sys.columns", loc8.ToString().Replace("a.table_name", "a.object_id"));
{ {
sql += "union all" + sql += "union all" +
string.Format(tsql_place.Replace( 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.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.parameter_id"), @"
,cast(0 as bit) 'IsNullable' ,cast(0 as bit) 'IsNullable'
,a.is_output 'IsIdentity' ,a.is_output 'IsIdentity'
from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id")); from sys.parameters", loc88.ToString().Replace("a.table_name", "a.object_id"));

View File

@ -26,7 +26,7 @@ namespace FreeSql.Sqlite.Curd
for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++) for (var tbUnionsIdx = 0; tbUnionsIdx < tbUnions.Count; tbUnionsIdx++)
{ {
if (tbUnionsIdx > 0) sb.Append(" \r\n\r\nUNION ALL\r\n\r\n"); 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 tbUnion = tbUnions[tbUnionsIdx];
var sbnav = new StringBuilder(); var sbnav = new StringBuilder();

View File

@ -211,7 +211,7 @@ namespace FreeSql.Sqlite
{ {
if (string.Concat(dbIndex[3]) == "pk") continue; if (string.Concat(dbIndex[3]) == "pk") continue;
var dbIndexesColumns = _orm.Ado.ExecuteArray(CommandType.Text, $"PRAGMA {_commonUtils.QuoteSqlName(tbtmp[0])}.INDEX_INFO({dbIndex[1]})"); 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) foreach (var dbcolumn in dbIndexesColumns)
{ {
var dbcolumnName = string.Concat(dbcolumn[2]); var dbcolumnName = string.Concat(dbcolumn[2]);