diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ExpressionContext.cs index 52136e468..67eb27bda 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ExpressionContext.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ExpressionContext.cs @@ -134,6 +134,7 @@ namespace SqlSugar copyContext.IsSingle = this.IsSingle; copyContext.RootExpression = this.RootExpression; copyContext.TableEnumIsString = this.TableEnumIsString; + copyContext.SugarContext = this.SugarContext; return copyContext; } public ExpressionContext GetCopyContextWithMapping() diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs index 3ba2bd0bf..1469ccc71 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs @@ -86,6 +86,12 @@ namespace SqlSugar 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 { ResolveMemberValue(parameter, baseParameter, isLeft, isSetTempData, expression); diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs index 820457e8e..cce1dc9e6 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs @@ -280,9 +280,16 @@ namespace SqlSugar 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)); + } } } diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs index a8d7895cb..3cda36124 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/OneToManyNavgateExpression.cs @@ -135,7 +135,10 @@ namespace SqlSugar } 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 selectName = this.ProPertyEntity.Columns.First(it => it.PropertyName == MemberName).DbColumnName; MapperSql mapper = new MapperSql();