Deveel.Data.Sql.Query.QueryTablePlanner.JoinAt C# (CSharp) Method

JoinAt() public method

public JoinAt ( int betweenIndex, JoinType joinType, SqlExpression onExpression ) : void
betweenIndex int
joinType JoinType
onExpression Deveel.Data.Sql.Expressions.SqlExpression
return void
        public void JoinAt(int betweenIndex, JoinType joinType, SqlExpression onExpression)
        {
            var planLeft = tablePlans[betweenIndex];
            var planRight = tablePlans[betweenIndex + 1];
            planLeft.RightJoin(planRight, joinType, onExpression);
            planRight.LeftJoin(planLeft, joinType, onExpression);
        }

Usage Example

Ejemplo n.º 1
0
        private void PrepareJoins(QueryTablePlanner tablePlanner, SqlQueryExpression queryExpression, QueryExpressionFrom queryFrom, ref SqlExpression searchExpression)
        {
            var fromClause = queryExpression.FromClause;

            bool allInner = true;

            for (int i = 0; i < fromClause.JoinPartCount; i++)
            {
                var joinPart = fromClause.GetJoinPart(i);
                if (joinPart.JoinType != JoinType.Inner)
                {
                    allInner = false;
                }
            }

            for (int i = 0; i < fromClause.JoinPartCount; i++)
            {
                var joinPart = fromClause.GetJoinPart(i);

                var joinType     = joinPart.JoinType;
                var onExpression = joinPart.OnExpression;

                if (allInner)
                {
                    // If the whole join set is inner joins then simply move the on
                    // expression (if there is one) to the WHERE clause.
                    if (searchExpression != null && onExpression != null)
                    {
                        searchExpression = SqlExpression.And(searchExpression, onExpression);
                    }
                    else if (searchExpression == null)
                    {
                        searchExpression = onExpression;
                    }
                }
                else
                {
                    // Not all inner joins,
                    if (joinType == JoinType.Inner && onExpression == null)
                    {
                        // Regular join with no ON expression, so no preparation necessary
                    }
                    else
                    {
                        // Either an inner join with an ON expression, or an outer join with
                        // ON expression
                        if (onExpression == null)
                        {
                            throw new InvalidOperationException(String.Format("Join of type {0} requires ON expression.", joinType));
                        }

                        // Resolve the on_expression
                        onExpression = onExpression.Prepare(queryFrom.ExpressionPreparer);
                        // And set it in the planner
                        tablePlanner.JoinAt(i, joinType, onExpression);
                    }
                }
            }
        }
All Usage Examples Of Deveel.Data.Sql.Query.QueryTablePlanner::JoinAt