mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Add constraint
This commit is contained in:
@@ -347,11 +347,13 @@ namespace SqlSugar
|
||||
else if (method.Method.Name == "Select")
|
||||
{
|
||||
var exp = method.Arguments[1];
|
||||
var newExp = (exp as LambdaExpression).Body;
|
||||
var types = exp.Type.GetGenericArguments();
|
||||
if (types != null && types.Length > 0)
|
||||
{
|
||||
var type = types[0];
|
||||
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)
|
||||
{
|
||||
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");
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>SqlSugarCore</id>
|
||||
<version>5.0.7.4</version>
|
||||
<version>5.0.7.5-preview01</version>
|
||||
<authors>sunkaixuan</authors>
|
||||
<owners>果糖大数据科技</owners>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||
|
Reference in New Issue
Block a user