mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Same as above
This commit is contained in:
parent
f08ccb9ad9
commit
b858c616d1
@ -435,8 +435,9 @@ namespace OrmTest
|
||||
var query8 = db.Queryable<Order>()
|
||||
.LeftJoin(db.Queryable<Custom>().Where(it=>it.Id==1),(o,i)=>o.CustomId==i.Id)
|
||||
.LeftJoin(db.Queryable<OrderItem>().Where(it=>it.OrderId==2),(o,i,item)=>item.OrderId==o.Id)
|
||||
.LeftJoin(db.Queryable<Order>().Where(it => it.Id >0), (o, i, item, od) => od.Id == o.Id)
|
||||
.Select(o => o).ToList();
|
||||
|
||||
|
||||
Console.WriteLine("#### Join Table End ####");
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,13 @@ namespace SqlSugar
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2> InnerJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression)
|
||||
@ -67,9 +71,13 @@ namespace SqlSugar
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2> RightJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression)
|
||||
@ -80,9 +88,13 @@ namespace SqlSugar
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2> LeftJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
@ -2576,35 +2588,47 @@ namespace SqlSugar
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2,T3> InnerJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T3>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2,T3>(this.Context.CurrentConnectionConfig);
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2,T3> RightJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T3>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2,T3>(this.Context.CurrentConnectionConfig);
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2,T3> LeftJoin<T3>(Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
@ -2972,35 +2996,47 @@ namespace SqlSugar
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3,T4> InnerJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T4>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3,T4>(this.Context.CurrentConnectionConfig);
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3,T4> RightJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T4>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3,T4>(this.Context.CurrentConnectionConfig);
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
joinInfo.TableName = "(" + sqlObject.Key + ")";
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3,T4> LeftJoin<T4>(Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
|
Loading…
Reference in New Issue
Block a user