Browse Source

Add constraint

pull/17/head
sunkaixuan 3 years ago
parent
commit
26da8525f6
  1. 7
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs
  2. 2
      Src/Asp.NetCore2/SqlSugar/SqlSugarForCore.nuspec

7
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs

@ -347,11 +347,13 @@ namespace SqlSugar
else if (method.Method.Name == "Select") else if (method.Method.Name == "Select")
{ {
var exp = method.Arguments[1]; var exp = method.Arguments[1];
var newExp = (exp as LambdaExpression).Body;
var types = exp.Type.GetGenericArguments(); var types = exp.Type.GetGenericArguments();
if (types != null && types.Length > 0) if (types != null && types.Length > 0)
{ {
var type = types[0]; var type = types[0];
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type); var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
Check.ExceptionEasy(newExp.Type != entityInfo.Type, $" new {newExp.Type .Name}is error ,use Select(it=>new {entityInfo.Type.Name})",$"new {newExp.Type.Name}是错误的,请使用Select(it=>new {entityInfo.Type.Name})");
if (entityInfo.Columns.Count(x => x.Navigat != null) == 0) if (entityInfo.Columns.Count(x => x.Navigat != null) == 0)
{ {
result.SelectString = (" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.SelectSingle).GetString()); result.SelectString = (" " + queryable.QueryBuilder.GetExpressionValue(exp, ResolveExpressType.SelectSingle).GetString());
@ -401,6 +403,11 @@ namespace SqlSugar
Check.Exception(isList == false, $"{_ListCallFunc.First()} need is ToList()", $"{_ListCallFunc.First()} 需要ToList"); Check.Exception(isList == false, $"{_ListCallFunc.First()} need is ToList()", $"{_ListCallFunc.First()} 需要ToList");
result.OrderByString = String.Join(" , ", oredrBy); result.OrderByString = String.Join(" , ", oredrBy);
} }
if (result.SelectString.HasValue())
{
Check.Exception(isList == false, $"{_ListCallFunc.First()} need is ToList()", $"{_ListCallFunc.First()} 需要ToList");
result.OrderByString = String.Join(" , ", oredrBy);
}
return result; return result;
} }

2
Src/Asp.NetCore2/SqlSugar/SqlSugarForCore.nuspec

@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>SqlSugarCore</id> <id>SqlSugarCore</id>
<version>5.0.7.4</version> <version>5.0.7.5-preview01</version>
<authors>sunkaixuan</authors> <authors>sunkaixuan</authors>
<owners>果糖大数据科技</owners> <owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>

Loading…
Cancel
Save