mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Optimized code
This commit is contained in:
parent
208e6932c9
commit
2f3c868cba
@ -73,14 +73,19 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string GetPackTable(string sql, string shortName)
|
||||
{
|
||||
return UtilMethods.GetPackTable(sql,shortName);
|
||||
return UtilMethods.GetPackTable(sql, shortName);
|
||||
}
|
||||
public virtual string GetDefaultShortName() {
|
||||
public virtual string GetDefaultShortName()
|
||||
{
|
||||
return "t";
|
||||
}
|
||||
public virtual string GetUnionAllSql(List<string> sqlList)
|
||||
{
|
||||
return string.Join("UNION ALL \r\n", sqlList);
|
||||
}
|
||||
public virtual void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex)
|
||||
{
|
||||
UtilMethods.RepairReplicationParameters(ref appendSql,parameters,addIndex);
|
||||
UtilMethods.RepairReplicationParameters(ref appendSql, parameters, addIndex);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -28,6 +28,7 @@ namespace SqlSugar
|
||||
string GetNoTranslationColumnName(string name);
|
||||
string GetPackTable(string sql,string shortName);
|
||||
string GetDefaultShortName();
|
||||
string GetUnionAllSql(List<string> sqlList);
|
||||
void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex);
|
||||
}
|
||||
}
|
||||
|
@ -310,6 +310,7 @@ namespace SqlSugar
|
||||
|
||||
public virtual ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
||||
{
|
||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||
int i = 1;
|
||||
List<KeyValuePair<string, List<SugarParameter>>> allItems = new List<KeyValuePair<string, List<SugarParameter>>>();
|
||||
@ -324,7 +325,7 @@ namespace SqlSugar
|
||||
allItems.Add(new KeyValuePair<string, List<SugarParameter>>(sql, new List<SugarParameter>()));
|
||||
i++;
|
||||
}
|
||||
var allSql = string.Join("UNION ALL \r\n", allItems.Select(it => it.Key));
|
||||
var allSql = sqlBuilder.GetUnionAllSql(allItems.Select(it => it.Key).ToList());
|
||||
var allParameters = allItems.SelectMany(it => it.Value).ToArray();
|
||||
var resulut = this.Queryable<ExpandoObject>().AS(UtilMethods.GetPackTable(allSql, "unionTable"));
|
||||
resulut.AddParameters(allParameters);
|
||||
|
Loading…
Reference in New Issue
Block a user