diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs index 8e53c3ed2..62807571c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs @@ -319,6 +319,12 @@ namespace SqlSugar { this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityService(property, column); } + if (column.PropertyInfo.DeclaringType != null + && column.PropertyInfo.DeclaringType != result.Type + &&result.Columns.Any(x=>x.PropertyName==column.PropertyName)) + { + continue; + } result.Columns.Add(column); } } diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs index 27180dd7a..aa0cbee0d 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs @@ -37,7 +37,7 @@ namespace SqlSugar } else { - InSubGroupBy(expression); + InSubGroupBy(expression, operatorValue=="<>"?"NOT":""); } return; } @@ -123,7 +123,7 @@ namespace SqlSugar } base.Context.Result.Append($" {leftSql} in ({rightSql}) "); } - private void InSubGroupBy(BinaryExpression expression) + private void InSubGroupBy(BinaryExpression expression,string not) { var leftSql = GetNewExpressionValue(expression.Left); var rightExpression = expression.Right as MethodCallExpression; @@ -139,12 +139,12 @@ namespace SqlSugar var p = (leftExp as MemberExpression); this.Context.SingleTableNameSubqueryShortName=p.Expression.ToString(); } - base.Context.Result.Append($" {leftSql} in ({rightSql}) "); + base.Context.Result.Append($" {leftSql} {not} in ({rightSql}) "); } private bool IsGroupSubquery(Expression rightExpression, string operatorValue) { - if (operatorValue != "=") + if (operatorValue != "="&& operatorValue != "<>") { return false; } diff --git a/Src/Asp.NetCore2/SqlSugar/Utilities/PropertyCallAdapterProvider.cs b/Src/Asp.NetCore2/SqlSugar/Utilities/PropertyCallAdapterProvider.cs index fd2060d35..9d57dd8e2 100644 --- a/Src/Asp.NetCore2/SqlSugar/Utilities/PropertyCallAdapterProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Utilities/PropertyCallAdapterProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; using System.Reflection; namespace SqlSugar @@ -33,9 +34,19 @@ namespace SqlSugar IPropertyCallAdapter instance; if (!_instances.TryGetValue(forPropertyName, out instance)) { - var property = typeof(TThis).GetProperty( - forPropertyName, - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + PropertyInfo property = null; + var propertys = typeof(TThis).GetProperties( + + BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) + .Where(it=>it.Name== forPropertyName); + if (propertys.Count() == 1) + { + property = propertys.First(); + } + else + { + property = propertys.First(); + } MethodInfo getMethod; Delegate getterInvocation = null;