From 15ccd4f51bf8189936a20e6c11e242f2828a4041 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 7 Dec 2022 10:05:11 +0800 Subject: [PATCH] Update Join --- .../QueryableProvider/QueryableProvider.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index 33b886132..559894bde 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -48,6 +48,12 @@ namespace SqlSugar public ISugarQueryable LeftJoin(ISugarQueryable joinQueryable, Expression> joinExpression) { + + if (MasterHasWhereFirstJoin()) + { + return this.MergeTable().LeftJoin(joinExpression); + } + this.Context.InitMappingInfo(); var result = InstanceFactory.GetQueryable(this.Context.CurrentConnectionConfig); result.SqlBuilder = this.SqlBuilder; @@ -65,6 +71,11 @@ namespace SqlSugar } public ISugarQueryable InnerJoin(ISugarQueryable joinQueryable, Expression> joinExpression) { + if (MasterHasWhereFirstJoin()) + { + return this.MergeTable().InnerJoin(joinExpression); + } + this.Context.InitMappingInfo(); var result = InstanceFactory.GetQueryable(this.Context.CurrentConnectionConfig); result.SqlBuilder = this.SqlBuilder; @@ -82,6 +93,12 @@ namespace SqlSugar } public ISugarQueryable RightJoin(ISugarQueryable joinQueryable, Expression> joinExpression) { + + if (MasterHasWhereFirstJoin()) + { + return this.MergeTable().RightJoin(joinExpression); + } + this.Context.InitMappingInfo(); var result = InstanceFactory.GetQueryable(this.Context.CurrentConnectionConfig); result.SqlBuilder = this.SqlBuilder; @@ -99,6 +116,12 @@ namespace SqlSugar } public ISugarQueryable FullJoin(ISugarQueryable joinQueryable, Expression> joinExpression) { + + if (MasterHasWhereFirstJoin()) + { + return this.MergeTable().FullJoin(joinExpression); + } + this.Context.InitMappingInfo(); var result = InstanceFactory.GetQueryable(this.Context.CurrentConnectionConfig); result.SqlBuilder = this.SqlBuilder; @@ -116,6 +139,11 @@ namespace SqlSugar } public ISugarQueryable LeftJoin(Expression> joinExpression) { + if (MasterHasWhereFirstJoin()) + { + return this.MergeTable().LeftJoin(joinExpression); + } + this.Context.InitMappingInfo(); var result = InstanceFactory.GetQueryable(this.Context.CurrentConnectionConfig); result.SqlBuilder = this.SqlBuilder;