mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-26 22:25:49 +08:00
Update Core
This commit is contained in:
@@ -289,7 +289,7 @@ namespace SqlSugar
|
||||
FieldValue = String.Join(",", ids),
|
||||
CSharpTypeName = listItemPkColumn.PropertyInfo.PropertyType.Name
|
||||
}));
|
||||
var sqlObj = GetWhereSql();
|
||||
var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name);
|
||||
|
||||
if (list.Any() && navObjectNamePropety.GetValue(list.First()) == null)
|
||||
{
|
||||
@@ -312,7 +312,7 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
|
||||
private SqlInfo GetWhereSql()
|
||||
private SqlInfo GetWhereSql(string properyName=null)
|
||||
{
|
||||
if (_ListCallFunc == null|| _ListCallFunc.Count==0) return new SqlInfo();
|
||||
List<string> where = new List<string>();
|
||||
@@ -376,6 +376,15 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
if (properyName != null)
|
||||
{
|
||||
var fkColumnsInfo = entityInfo.Columns.FirstOrDefault(x => x.PropertyName == properyName);
|
||||
if (fkColumnsInfo != null)
|
||||
{
|
||||
var fkName = fkColumnsInfo.DbColumnName;
|
||||
AppColumns(result, queryable, fkName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (method.Method.Name == "OrderByDescending")
|
||||
|
||||
@@ -853,8 +853,22 @@ namespace SqlSugar
|
||||
return this.Select("1").ToList().Count() > 0;
|
||||
}
|
||||
|
||||
public virtual List<TResult> ToList<TResult>(Expression<Func<T, TResult>> expression)
|
||||
{
|
||||
if (this.QueryBuilder.Includes.Count > 0)
|
||||
{
|
||||
var list = this.ToList().Select(expression.Compile()).ToList();
|
||||
return list;
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = this.Select(expression).ToList();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
public virtual ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression)
|
||||
{
|
||||
Check.ExceptionEasy(this.QueryBuilder.Includes.HasValue(), $"use Includes(...).ToList(it=>new {typeof(TResult).Name} {{...}} )", $"Includes()后面禁使用Select,正确写法: ToList(it=>new {typeof(TResult).Name}{{....}})");
|
||||
return _Select<TResult>(expression);
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace SqlSugar
|
||||
Task<TResult> AvgAsync<TResult>(string avgField);
|
||||
TResult Avg<TResult>(Expression<Func<T, TResult>> expression);
|
||||
Task<TResult> AvgAsync<TResult>(Expression<Func<T, TResult>> expression);
|
||||
|
||||
List<TResult> ToList<TResult>(Expression<Func<T, TResult>> expression);
|
||||
List<T> ToList();
|
||||
List<T> SetContext<ParameterT>(Expression<Func<T,object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter);
|
||||
Task <List<T>> SetContextAsync<ParameterT>(Expression<Func<T, object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter);
|
||||
|
||||
Reference in New Issue
Block a user