Example #1
0
        public ITableInfo VisitSqlJoinedTable(SqlJoinedTable joinedTable)
        {
            ArgumentUtility.CheckNotNull("joinedTable", joinedTable);

            var newJoinInfo = _stage.ApplyContext(joinedTable.JoinInfo, _expressionContext, _mappingResolutionContext);

            joinedTable.JoinInfo = newJoinInfo;

            return(joinedTable);
        }
        public IJoinInfo VisitResolvedJoinInfo(ResolvedJoinInfo joinInfo)
        {
            ArgumentUtility.CheckNotNull("joinInfo", joinInfo);

            var newTableInfo = (IResolvedTableInfo)_stage.ApplyContext(joinInfo.ForeignTableInfo, _expressionContext, _mappingResolutionContext);

            if (joinInfo.ForeignTableInfo != newTableInfo)
            {
                return(new ResolvedJoinInfo(newTableInfo, joinInfo.JoinCondition));
            }
            return(joinInfo);
        }
Example #3
0
        public SqlStatement VisitSqlStatement(SqlStatement sqlStatement, SqlExpressionContext expressionContext)
        {
            ArgumentUtility.CheckNotNull("sqlStatement", sqlStatement);

            if (expressionContext == SqlExpressionContext.PredicateRequired)
            {
                throw new InvalidOperationException("A SqlStatement cannot be used as a predicate.");
            }

            var statementBuilder = new SqlStatementBuilder(sqlStatement);

            var newSelectProjection = _stage.ApplyContext(sqlStatement.SelectProjection, expressionContext, _mappingResolutionContext);

            statementBuilder.SelectProjection = newSelectProjection;
            statementBuilder.RecalculateDataInfo(sqlStatement.SelectProjection);

            var newSqlStatement = statementBuilder.GetSqlStatement();

            return(newSqlStatement.Equals(sqlStatement) ? sqlStatement : newSqlStatement);
        }