Browse Source

Update Core

pull/17/head
sunkaixuan 3 years ago
parent
commit
bee87bb86f
  1. 2
      Src/Asp.Net/SqlSugar/SqlSugar.nuspec
  2. 13
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs
  3. 14
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  4. 2
      Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs

2
Src/Asp.Net/SqlSugar/SqlSugar.nuspec

@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>SqlSugar</id> <id>SqlSugar</id>
<version>5.0.7.4</version> <version>5.0.7.5</version>
<title>SqlSugar .NET ORM Framework 版本, 5.0.3.3-max 最低要求 .Net Framework 4.6 | 5.0.0.2-5.0.3.2 最低要求 .Net Framework 4.5 | 4.0-4.9.11 最低要求 .Net Framework 4.0+ .NET ORM </title> <title>SqlSugar .NET ORM Framework 版本, 5.0.3.3-max 最低要求 .Net Framework 4.6 | 5.0.0.2-5.0.3.2 最低要求 .Net Framework 4.5 | 4.0-4.9.11 最低要求 .Net Framework 4.0+ .NET ORM </title>
<authors>sun kaixuan</authors> <authors>sun kaixuan</authors>
<owners>landa</owners> <owners>landa</owners>

13
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs

@ -289,7 +289,7 @@ namespace SqlSugar
FieldValue = String.Join(",", ids), FieldValue = String.Join(",", ids),
CSharpTypeName = listItemPkColumn.PropertyInfo.PropertyType.Name CSharpTypeName = listItemPkColumn.PropertyInfo.PropertyType.Name
})); }));
var sqlObj = GetWhereSql(); var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name);
if (list.Any() && navObjectNamePropety.GetValue(list.First()) == null) 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(); if (_ListCallFunc == null|| _ListCallFunc.Count==0) return new SqlInfo();
List<string> where = new List<string>(); 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") else if (method.Method.Name == "OrderByDescending")

14
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -853,8 +853,22 @@ namespace SqlSugar
return this.Select("1").ToList().Count() > 0; 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) 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); return _Select<TResult>(expression);
} }

2
Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs

@ -132,7 +132,7 @@ namespace SqlSugar
Task<TResult> AvgAsync<TResult>(string avgField); Task<TResult> AvgAsync<TResult>(string avgField);
TResult Avg<TResult>(Expression<Func<T, TResult>> expression); TResult Avg<TResult>(Expression<Func<T, TResult>> expression);
Task<TResult> AvgAsync<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> ToList();
List<T> SetContext<ParameterT>(Expression<Func<T,object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter); 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); Task <List<T>> SetContextAsync<ParameterT>(Expression<Func<T, object>> thisFiled, Expression<Func<object>> mappingFiled, ParameterT parameter);

Loading…
Cancel
Save