diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index 512fb83dc..d1489fa53 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -334,14 +334,14 @@ namespace SqlSugar } public IDeleteable WhereColumns(List list,Expression> columns) { - if (this.GetPrimaryKeys().IsNullOrEmpty()) - { - tempPrimaryKeys = DeleteBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); - } - else if (columns != null && tempPrimaryKeys.IsNullOrEmpty()) + if (columns!=null) { tempPrimaryKeys = DeleteBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); } + //else if (columns != null && tempPrimaryKeys.IsNullOrEmpty()) + //{ + // tempPrimaryKeys = DeleteBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList(); + //} this.Where(list); return this; diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs index ec11b94e9..ae8f8b234 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSql.cs @@ -340,7 +340,7 @@ namespace SqlSugar } return result; } - public List ToTree(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue) + public List ToTree(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, Expression> primaryKeyExpression) { var entity = this.Context.EntityMaintenance.GetEntityInfo(); var pk = ExpressionTool.GetMemberName(primaryKeyExpression); @@ -359,7 +359,7 @@ namespace SqlSugar var list = this.ToList(); return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list) ?? new List(); } - public List ToTree(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue, object[] childIds) + public List ToTree(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, object[] childIds, Expression> primaryKeyExpression) { var list = this.ToList(); return TreeAndFilterIds(childListExpression, parentIdExpression,primaryKeyExpression, rootValue, childIds, ref list) ?? new List(); diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs index 7061c178c..0fa733ab7 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableExecuteSqlAsync.cs @@ -585,7 +585,7 @@ ParameterT parameter) var list = await this.ToListAsync(); return TreeAndFilterIds(childListExpression, parentIdExpression, rootValue, childIds, ref list) ?? new List(); } - public async Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue, object[] childIds) + public async Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, object[] childIds, Expression> primaryKeyExpression) { var list = await this.ToListAsync(); return TreeAndFilterIds(childListExpression, parentIdExpression,primaryKeyExpression, rootValue, childIds, ref list) ?? new List(); @@ -597,7 +597,7 @@ ParameterT parameter) var list = await this.ToListAsync(); return GetTreeRoot(childListExpression, parentIdExpression, pk, list, rootValue) ?? new List(); } - public async Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue) + public async Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, Expression> primaryKeyExpression) { var entity = this.Context.EntityMaintenance.GetEntityInfo(); var pk = ExpressionTool.GetMemberName(primaryKeyExpression); ; diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs index 72969ebcc..7f6aeec69 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs @@ -207,7 +207,14 @@ namespace SqlSugar result.AsUpdateable.WhereColumns(whereExpression); result.AsDeleteable.WhereColumns(update.Select(it => it.Item).ToList(),whereExpression); } - result.AsDeleteable.Where(delete.Select(it => it.Item).ToList()); + if (this.whereExpression != null) + { + result.AsDeleteable.WhereColumns(delete.Select(it => it.Item).ToList(), whereExpression); + } + else + { + result.AsDeleteable.Where(delete.Select(it => it.Item).ToList()); + } return result; } diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs index 189aebe21..e05bd0821 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs @@ -233,13 +233,13 @@ namespace SqlSugar Task> ToParentListAsync(Expression> parentIdExpression, object primaryKeyValue, Expression> parentWhereExpression); List ToTree(Expression>> childListExpression, Expression> parentIdExpression,object rootValue); - List ToTree(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue); + List ToTree(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, Expression> primaryKeyExpression); Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, object rootValue); - Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue); + Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, Expression> primaryKeyExpression); List ToTree(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, object[] childIds); - List ToTree(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue, object[] childIds); + List ToTree(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, object[] childIds, Expression> primaryKeyExpression); Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, object[] childIds); - Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, Expression> primaryKeyExpression, object rootValue, object[] childIds); + Task> ToTreeAsync(Expression>> childListExpression, Expression> parentIdExpression, object rootValue, object[] childIds, Expression> primaryKeyExpression); DataTable ToDataTable(); DataTable ToDataTableByEntity(); Task ToDataTableAsync();