From a16658623d80e77ba1c1d9a7519dca69724d812f Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 28 Apr 2025 15:06:01 +0800 Subject: [PATCH] Add queryable.LeftJoinIF(queryable) --- .../QueryableProvider06-10.cs | 90 +++++++++++++++++++ .../QueryableProvider11-12.cs | 18 ++++ .../SqlSugar/Interface/IQueryable.cs | 10 +++ 3 files changed, 118 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs index 2791c19c0..11e58118a 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs @@ -110,6 +110,24 @@ namespace SqlSugar result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; return result; } + public ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = LeftJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } + public ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = InnerJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } public ISugarQueryable LeftJoin(Expression> joinExpression) { this.Context.InitMappingInfo(); @@ -924,6 +942,24 @@ namespace SqlSugar result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; return result; } + public ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = LeftJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } + public ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = InnerJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } public ISugarQueryable LeftJoin(Expression> joinExpression) { this.Context.InitMappingInfo(); @@ -1747,6 +1783,24 @@ namespace SqlSugar result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; return result; } + public ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = LeftJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } + public ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = InnerJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } public ISugarQueryable LeftJoin(Expression> joinExpression) { this.Context.InitMappingInfo(); @@ -2506,6 +2560,24 @@ namespace SqlSugar result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; return result; } + public ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = LeftJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } + public ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = InnerJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } public ISugarQueryable LeftJoin(Expression> joinExpression) { this.Context.InitMappingInfo(); @@ -3275,6 +3347,24 @@ namespace SqlSugar result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; return result; } + public ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = LeftJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } + public ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = InnerJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } public ISugarQueryable LeftJoin(Expression> joinExpression) { this.Context.InitMappingInfo(); diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs index 9053c00b6..59d40cef5 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs @@ -106,6 +106,24 @@ namespace SqlSugar result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex; return result; } + public ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = LeftJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } + public ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression) + { + var result = InnerJoin(joinQueryable, joinExpression); + if (isJoin == false) + { + result.QueryBuilder.JoinQueryInfos.Remove(result.QueryBuilder.JoinQueryInfos.Last()); + } + return result; + } public ISugarQueryable LeftJoin(Expression> joinExpression) { this.Context.InitMappingInfo(); diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs index 80e7f5a23..4f9a6bc2e 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IQueryable.cs @@ -934,6 +934,8 @@ namespace SqlSugar ISugarQueryable SelectMergeTable(Expression> expression); ISugarQueryable LeftJoinIF(bool isLeftJoin, Expression> joinExpression); ISugarQueryable InnerJoinIF(bool isJoin, Expression> joinExpression); + ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable LeftJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable InnerJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable RightJoin(ISugarQueryable joinQueryable, Expression> joinExpression); @@ -1091,6 +1093,8 @@ namespace SqlSugar ISugarQueryable LeftJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable InnerJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable RightJoin(ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable LeftJoin(Expression> joinExpression); ISugarQueryable FullJoin(Expression> joinExpression); ISugarQueryable InnerJoin(Expression> joinExpression); @@ -1240,6 +1244,8 @@ namespace SqlSugar ISugarQueryable LeftJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable InnerJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable RightJoin(ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable LeftJoin(Expression> joinExpression); ISugarQueryable FullJoin(Expression> joinExpression); ISugarQueryable InnerJoin(Expression> joinExpression); @@ -1390,6 +1396,8 @@ namespace SqlSugar ISugarQueryable LeftJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable InnerJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable RightJoin(ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable LeftJoin(Expression> joinExpression); ISugarQueryable FullJoin(Expression> joinExpression); ISugarQueryable InnerJoin(Expression> joinExpression); @@ -1679,6 +1687,8 @@ namespace SqlSugar ISugarQueryable LeftJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable InnerJoin(ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable RightJoin(ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable LeftJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); + ISugarQueryable InnerJoinIF(bool isJoin, ISugarQueryable joinQueryable, Expression> joinExpression); ISugarQueryable LeftJoin(Expression> joinExpression); ISugarQueryable FullJoin(Expression> joinExpression); ISugarQueryable InnerJoin(Expression> joinExpression);