diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs index 500555757..7d7f325db 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs @@ -565,7 +565,25 @@ namespace SqlSugar //additem.Value = ""; result.Add(additem); } - else + else if (memberAssignment.Expression is MemberInitExpression|| memberAssignment.Expression is NewExpression) + { + + var dic = ExpressionTool.GetNewExpressionItemList(memberAssignment.Expression); + foreach (var kv in dic) + { + additem = new NewExpressionInfo(); + //var leftInfo = keys[i]; + additem.Type = nameof(NewExpression); + additem.RightName = kv.Key; + additem.ShortName = ExpressionTool.GetParameters(kv.Value).First().Name; + additem.RightName = kv.Key; + additem.LeftNameName = memberAssignment.Member.Name + "." + kv.Key; + additem.RightDbName = kv.Key; + //additem.Value = ""; + result.Add(additem); + } + } + else { var value = baseResolve.GetNewExpressionValue(memberAssignment.Expression); //var leftInfo = keys[i]; diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Item.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Item.cs index 2aa20ded2..d3c2ba3c8 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Item.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Item.cs @@ -104,7 +104,7 @@ namespace SqlSugar this.Context.SqlTranslationLeft + asName + "." + newExpressionInfo.LeftNameName + this.Context.SqlTranslationRight ); - } + } else { parameter.Context.Result.Append(this.Context.GetAsString( diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Property.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Property.cs index 025ec34bb..85473b43b 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Property.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve_Property.cs @@ -68,7 +68,7 @@ namespace SqlSugar if (first.Contains("(")) { first = first.Split('(').Last().Trim(); - } + } if (!result.ContainsKey(first)) { result.Add(first, last); diff --git a/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs b/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs index 8246d4486..521e6a3dd 100644 --- a/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs +++ b/Src/Asp.NetCore2/SqlSugar/Infrastructure/ContextMethods.cs @@ -659,6 +659,10 @@ namespace SqlSugar { key = item.Name + "." + name; info = readerValues.Select(it => it.Key).FirstOrDefault(it => it.ToLower() == key.ToLower()); + if (info == null) + { + info = readerValues.Select(it => it.Key).FirstOrDefault(it => it.ToLower().EndsWith("."+ key.ToLower())); + } } var oldInfo = info; if (mappingKeys != null && mappingKeys.ContainsKey(item.Name))