Browse Source

Update Core

pull/19/head
sunkaixuan 3 years ago
parent
commit
2c25ed6226
  1. 1
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ExpressionContext.cs
  2. 6
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs
  3. 11
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs
  4. 5
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs

1
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ExpressionContext.cs

@ -134,6 +134,7 @@ namespace SqlSugar
copyContext.IsSingle = this.IsSingle; copyContext.IsSingle = this.IsSingle;
copyContext.RootExpression = this.RootExpression; copyContext.RootExpression = this.RootExpression;
copyContext.TableEnumIsString = this.TableEnumIsString; copyContext.TableEnumIsString = this.TableEnumIsString;
copyContext.SugarContext = this.SugarContext;
return copyContext; return copyContext;
} }
public ExpressionContext GetCopyContextWithMapping() public ExpressionContext GetCopyContextWithMapping()

6
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -86,6 +86,12 @@ namespace SqlSugar
AppendValue(parameter, isLeft, value); AppendValue(parameter, isLeft, value);
} }
} }
else if(expression.Expression is UnaryExpression&&(expression.Expression as UnaryExpression).Operand is ParameterExpression)
{
var memParameter = (expression.Expression as UnaryExpression).Operand as ParameterExpression;
var name = ExpressionTool.GetMemberName(expression);
this.Context.Result.Append(this.Context.GetTranslationColumnName(memParameter.Name+"."+name));
}
else else
{ {
ResolveMemberValue(parameter, baseParameter, isLeft, isSetTempData, expression); ResolveMemberValue(parameter, baseParameter, isLeft, isSetTempData, expression);

11
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -280,9 +280,16 @@ namespace SqlSugar
base.AppendValue(parameter, isLeft, parameterName); base.AppendValue(parameter, isLeft, parameterName);
} }
} }
catch catch(Exception ex)
{ {
Check.Exception(true, string.Format(ErrorMessage.MethodError, express.Method.Name)); if (ex is SqlSugarException)
{
Check.Exception(true, string.Format(ex.Message, express.Method.Name));
}
else
{
Check.Exception(true, string.Format(ErrorMessage.MethodError, express.Method.Name));
}
} }
} }

5
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs

@ -135,7 +135,10 @@ namespace SqlSugar
} }
private MapperSql GetOneToManySql() private MapperSql GetOneToManySql()
{ {
var pk = this.EntityInfo.Columns.First(it => it.IsPrimarykey == true).DbColumnName; var pkColumn = this.EntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey == true);
Check.ExceptionEasy(pkColumn == null, $"{this.EntityInfo.EntityName} need primary key ",
$"导航属性 {this.EntityInfo.EntityName}需要主键");
var pk = pkColumn.DbColumnName;
var name = this.ProPertyEntity.Columns.First(it => it.PropertyName == Navigat.Name).DbColumnName; var name = this.ProPertyEntity.Columns.First(it => it.PropertyName == Navigat.Name).DbColumnName;
//var selectName = this.ProPertyEntity.Columns.First(it => it.PropertyName == MemberName).DbColumnName; //var selectName = this.ProPertyEntity.Columns.First(it => it.PropertyName == MemberName).DbColumnName;
MapperSql mapper = new MapperSql(); MapperSql mapper = new MapperSql();

Loading…
Cancel
Save