diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs index 0fce15abc..783841b44 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs @@ -160,55 +160,55 @@ namespace SqlSugar var result = this.Context.EntityMaintenance.GetEntityInfo(type); return result; }); - var copyObj = CopyEntityInfo(entityInfo); - InitMappingInfo(copyObj); + //var copyObj = CopyEntityInfo(entityInfo); + InitMappingInfo(entityInfo); } public void InitMappingInfoNoCache(Type type) { var entityInfo = this.Context.EntityMaintenance.GetEntityInfoNoCache(type); InitMappingInfo(entityInfo); } - private EntityInfo CopyEntityInfo(EntityInfo entityInfo) - { - EntityInfo result = new EntityInfo() - { - DbTableName = entityInfo.DbTableName, - EntityName = entityInfo.EntityName, - Type = entityInfo.Type - }; - List columns = new List(); - if (entityInfo.Columns.HasValue()) - { - foreach (var item in entityInfo.Columns) - { - EntityColumnInfo column = new EntityColumnInfo() - { - ColumnDescription = item.ColumnDescription, - DataType = item.DataType, - DbColumnName = item.DbColumnName, - DbTableName = item.DbTableName, - DecimalDigits = item.DecimalDigits, - DefaultValue = item.DefaultValue, - EntityName = item.EntityName, - IsIdentity = item.IsIdentity, - IsIgnore = item.IsIgnore, - IsNullable = item.IsNullable, - IsOnlyIgnoreInsert = item.IsOnlyIgnoreInsert, - IsPrimarykey = item.IsPrimarykey, - Length = item.Length, - OldDbColumnName = item.OldDbColumnName, - OracleSequenceName = item.OracleSequenceName, - PropertyInfo = item.PropertyInfo, - PropertyName = item.PropertyName, - IsArray=item.IsArray, - IsJson=item.IsJson - }; - columns.Add(item); - } - } - result.Columns = columns; - return result; - } + //private EntityInfo CopyEntityInfo(EntityInfo entityInfo) + //{ + // EntityInfo result = new EntityInfo() + // { + // DbTableName = entityInfo.DbTableName, + // EntityName = entityInfo.EntityName, + // Type = entityInfo.Type + // }; + // List columns = new List(); + // if (entityInfo.Columns.HasValue()) + // { + // foreach (var item in entityInfo.Columns) + // { + // EntityColumnInfo column = new EntityColumnInfo() + // { + // ColumnDescription = item.ColumnDescription, + // DataType = item.DataType, + // DbColumnName = item.DbColumnName, + // DbTableName = item.DbTableName, + // DecimalDigits = item.DecimalDigits, + // DefaultValue = item.DefaultValue, + // EntityName = item.EntityName, + // IsIdentity = item.IsIdentity, + // IsIgnore = item.IsIgnore, + // IsNullable = item.IsNullable, + // IsOnlyIgnoreInsert = item.IsOnlyIgnoreInsert, + // IsPrimarykey = item.IsPrimarykey, + // Length = item.Length, + // OldDbColumnName = item.OldDbColumnName, + // OracleSequenceName = item.OracleSequenceName, + // PropertyInfo = item.PropertyInfo, + // PropertyName = item.PropertyName, + // IsArray=item.IsArray, + // IsJson=item.IsJson + // }; + // columns.Add(item); + // } + // } + // result.Columns = columns; + // return result; + //} private void InitMappingInfo(EntityInfo entityInfo) { diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs index 0b1dd3d06..44f01fb18 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableHelper.cs @@ -106,14 +106,19 @@ namespace SqlSugar var diffColumns = FastCopy.GetDiff(item, (T)trackingData.Value); if (diffColumns.Count > 0) { - var pks =EntityInfo.Columns + var pks = EntityInfo.Columns .Where(it => it.IsPrimarykey).Select(it => it.PropertyName).ToList(); - diffColumns=diffColumns.Where(it => !pks.Contains(it)).ToList(); + diffColumns = diffColumns.Where(it => !pks.Contains(it)).ToList(); if (diffColumns.Count > 0) { this.UpdateColumns(diffColumns.ToArray()); } } + else + { + this.UpdateObjs = new T [] { null }; + this.UpdateBuilder.DbColumnInfoList = new List(); + } } } diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs index ef1e330b0..49266790b 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs @@ -162,6 +162,20 @@ namespace SqlSugar { var leftSql = GetNewExpressionValue(expression.Left); var rightExpression = expression.Right as MethodCallExpression; + if (rightExpression.Arguments[0] is LambdaExpression) + { + if ((rightExpression.Arguments[0] as LambdaExpression).Parameters?.Count > 0) + { + foreach (var item in (rightExpression.Arguments[0] as LambdaExpression).Parameters) + { + if (this.Context.InitMappingInfo != null) + { + this.Context.InitMappingInfo(item.Type); + this.Context.RefreshMapping(); + } + } + } + } var selector = GetNewExpressionValue(rightExpression.Arguments[0]); var selectorExp = rightExpression.Arguments[0]; if (selector.Contains(".") && selectorExp is LambdaExpression)