public virtual JoinQueryResult ToJoinQueryResult(JoinType joinType, LambdaExpression conditionExpression, DbFromTableExpression fromTable, List <IMappingObjectExpression> moeList, string tableAlias) { DbSqlQueryExpression sqlQuery = this.CreateSqlQuery(); DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery); string alias = tableAlias; DbTableSegment tableSeg = new DbTableSegment(subQuery, alias); DbTable table = new DbTable(tableSeg.Alias); IMappingObjectExpression newMoe = this.Result.MappingObjectExpression.ToNewObjectExpression(sqlQuery, table); List <IMappingObjectExpression> moes = new List <IMappingObjectExpression>(moeList.Count + 1); moes.AddRange(moeList); moes.Add(newMoe); DbExpression condition = GeneralExpressionVisitor.ParseLambda(conditionExpression, moes); DbJoinTableExpression joinTable = new DbJoinTableExpression(joinType.AsDbJoinType(), tableSeg, condition); JoinQueryResult result = new JoinQueryResult(); result.MappingObjectExpression = newMoe; result.JoinTable = joinTable; return(result); }
public override JoinQueryResult ToJoinQueryResult(JoinType joinType, LambdaExpression conditionExpression, ScopeParameterDictionary scopeParameters, StringSet scopeTables, Func <string, string> tableAliasGenerator) { scopeParameters = scopeParameters.Clone(conditionExpression.Parameters.Last(), this.QueryModel.ResultModel); DbExpression condition = GeneralExpressionParser.Parse(conditionExpression, scopeParameters, scopeTables); DbJoinTableExpression joinTable = new DbJoinTableExpression(joinType.AsDbJoinType(), this.QueryModel.FromTable.Table, condition); if (!this.QueryModel.IgnoreFilters) { joinTable.Condition = joinTable.Condition.And(this.QueryModel.ContextFilters).And(this.QueryModel.GlobalFilters); } JoinQueryResult result = new JoinQueryResult(); result.ResultModel = this.QueryModel.ResultModel; result.JoinTable = joinTable; return(result); }
public virtual JoinQueryResult ToJoinQueryResult(JoinType joinType, LambdaExpression conditionExpression, ScopeParameterDictionary scopeParameters, KeyDictionary<string> scopeTables, string tableAlias) { DbSqlQueryExpression sqlQuery = this.CreateSqlQuery(); DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery); string alias = tableAlias; DbTableSegment tableSeg = new DbTableSegment(subQuery, alias); DbTable table = new DbTable(tableSeg.Alias); IMappingObjectExpression newMoe = this.Result.MappingObjectExpression.ToNewObjectExpression(sqlQuery, table); scopeParameters[conditionExpression.Parameters[conditionExpression.Parameters.Count - 1]] = newMoe; DbExpression condition = GeneralExpressionVisitor.ParseLambda(conditionExpression, scopeParameters, scopeTables); DbJoinTableExpression joinTable = new DbJoinTableExpression(joinType.AsDbJoinType(), tableSeg, condition); JoinQueryResult result = new JoinQueryResult(); result.MappingObjectExpression = newMoe; result.JoinTable = joinTable; return result; }
public virtual JoinQueryResult ToJoinQueryResult(JoinType joinType, LambdaExpression conditionExpression, ScopeParameterDictionary scopeParameters, StringSet scopeTables, string tableAlias) { DbSqlQueryExpression sqlQuery = this.CreateSqlQuery(); DbSubQueryExpression subQuery = new DbSubQueryExpression(sqlQuery); string alias = tableAlias; DbTableSegment tableSeg = new DbTableSegment(subQuery, alias, LockType.Unspecified); DbJoinTableExpression joinTable = new DbJoinTableExpression(joinType.AsDbJoinType(), tableSeg); DbTable aliasTable = new DbTable(tableSeg.Alias); IObjectModel newModel = this.QueryModel.ResultModel.ToNewObjectModel(sqlQuery, aliasTable, joinTable); scopeParameters[conditionExpression.Parameters[conditionExpression.Parameters.Count - 1]] = newModel; DbExpression condition = GeneralExpressionParser.Parse(conditionExpression, scopeParameters, scopeTables); joinTable.Condition = condition; JoinQueryResult result = new JoinQueryResult(); result.ResultModel = newModel; result.JoinTable = joinTable; return(result); }