Update Subquery.ToList

This commit is contained in:
sunkaixuan
2022-12-04 03:58:24 +08:00
parent e36d8dbd71
commit 78874a172c
7 changed files with 41 additions and 8 deletions

View File

@@ -1510,15 +1510,18 @@ namespace SqlSugar
{ {
var item = result[i]; var item = result[i];
var setValue = Activator.CreateInstance(itemProperty.PropertyType, true) as IList; var setValue = Activator.CreateInstance(itemProperty.PropertyType, true) as IList;
var appindex = 0; if (appendValue != null)
foreach (var appValue in appendValue)
{ {
if (appValue[0].Value.ObjToInt() == i) var appindex = 0;
foreach (var appValue in appendValue)
{ {
var addItem = list[appindex]; if (appValue[0].Value.ObjToInt() == i)
setValue.Add(addItem); {
var addItem = list[appindex];
setValue.Add(addItem);
}
appindex++;
} }
appindex++;
} }
var jobj = JObject.FromObject(item); var jobj = JObject.FromObject(item);
var prop = jobj.Property(itemProperty.Name); var prop = jobj.Property(itemProperty.Name);

View File

@@ -850,6 +850,7 @@ namespace SqlSugar
#region NoCopy #region NoCopy
internal bool IsClone { get; set; } internal bool IsClone { get; set; }
public bool NoCheckInclude { get; set; } public bool NoCheckInclude { get; set; }
public virtual bool IsSelectNoAll { get; set; } = false;
#endregion #endregion
private string GetTableName(string entityName) private string GetTableName(string entityName)

View File

@@ -111,7 +111,7 @@ namespace SqlSugar
public bool Contains(string value) public bool Contains(string value)
{ {
if (this.Result.Equals(value)) return true; if (this.Result.Equals(value)) return true;
return (this.Result.ToString().Contains(value)); return (this.Result.ToString().ToLower().Contains(value?.ToLower()));
} }
internal void Insert(int index, string value) internal void Insert(int index, string value)

View File

@@ -45,8 +45,24 @@ namespace SqlSugar
{; {;
var exp = expression as MethodCallExpression; var exp = expression as MethodCallExpression;
InitType(exp); InitType(exp);
if (exp.Arguments.Count == 0) var type=expression.Type;
if (type.FullName.IsCollectionsList()
&& exp.Arguments.Count == 0&& type.GenericTypeArguments.Length>0
&& this.Context.SugarContext!=null
&&this.Context.SugarContext.QueryBuilder.IsSelectNoAll)
{
var entity = type.GenericTypeArguments[0];
var columnNames=this.Context.SugarContext.Context.EntityMaintenance.GetEntityInfo(entity).Columns;
var columnsString = string.Join(",", columnNames
.Where(it => it.IsIgnore == false)
.Where(it => it.DbColumnName.HasValue())
.Select(it => this.Context.GetTranslationColumnName(it.DbColumnName)));
return $"{columnsString},@sugarIndex as sugarIndex";
}
else if (exp.Arguments.Count == 0)
{
return "*,@sugarIndex as sugarIndex"; return "*,@sugarIndex as sugarIndex";
}
var argExp = exp.Arguments[0]; var argExp = exp.Arguments[0];
var parametres = (argExp as LambdaExpression).Parameters; var parametres = (argExp as LambdaExpression).Parameters;
if ((argExp as LambdaExpression).Body is UnaryExpression) if ((argExp as LambdaExpression).Body is UnaryExpression)

View File

@@ -50,6 +50,14 @@ namespace SqlSugar
var result = base.GetTranslationColumnName(propertyName); var result = base.GetTranslationColumnName(propertyName);
return result.ToUpper(); return result.ToUpper();
} }
public override string RemoveParentheses(string sql)
{
if (sql.StartsWith("(") && sql.EndsWith(")"))
{
sql = sql.Substring(1, sql.Length - 2);
}
return sql;
}
} }
} }

View File

@@ -9,6 +9,7 @@ namespace SqlSugar
{ {
public class OracleQueryBuilder : QueryBuilder public class OracleQueryBuilder : QueryBuilder
{ {
public override bool IsSelectNoAll { get; set; } = true;
public override bool IsComplexModel(string sql) public override bool IsComplexModel(string sql)
{ {
return Regex.IsMatch(sql, @"AS ""\w+\.\w+""")|| Regex.IsMatch(sql, @"AS ""\w+\.\w+\.\w+"""); return Regex.IsMatch(sql, @"AS ""\w+\.\w+""")|| Regex.IsMatch(sql, @"AS ""\w+\.\w+\.\w+""");

View File

@@ -148,6 +148,10 @@ namespace SqlSugar
{ {
result = " DISTINCT " + result; result = " DISTINCT " + result;
} }
if (this.SubToListParameters != null && this.SubToListParameters.Any())
{
result = SubToListMethod(result);
}
return result; return result;
} }
} }