public void Remove(InputFragment fragment)
        {
            if (fragment == null)
            {
                return;
            }
            if (fragment.Name != null)
            {
                scopeTable.Remove(fragment.Name);
            }

            if (fragment is SelectStatement)
            {
                Remove((fragment as SelectStatement).From);
            }
            else if (fragment is JoinFragment)
            {
                JoinFragment j = fragment as JoinFragment;
                Remove(j.Left);
                Remove(j.Right);
            }
            else if (fragment is UnionFragment)
            {
                UnionFragment u = fragment as UnionFragment;
                Remove(u.Left);
                Remove(u.Right);
            }
        }
        private SqlFragment HandleJoinExpression(DbExpressionBinding left, DbExpressionBinding right,
                                                 DbExpressionKind joinType, DbExpression joinCondition)
        {
            JoinFragment join = new JoinFragment();

            join.JoinType = Metadata.GetOperator(joinType);

            join.Left = VisitInputExpression(left.Expression, left.VariableName, left.VariableType);
            join.Left = WrapJoinInputIfNecessary(join.Left, false);

            join.Right = VisitInputExpression(right.Expression, right.VariableName, right.VariableType);
            join.Right = WrapJoinInputIfNecessary(join.Right, true);

            if (join.Right is SelectStatement)
            {
                SelectStatement select = join.Right as SelectStatement;
                if (select.IsWrapped)
                {
                    select.Name = right.VariableName;
                }
            }

            // now handle the ON case
            if (joinCondition != null)
            {
                join.Condition = joinCondition.Accept(this);
            }
            return(join);
        }
        private SqlFragment HandleJoinExpression(DbExpressionBinding left, DbExpressionBinding right,
            DbExpressionKind joinType, DbExpression joinCondition)
        {
            JoinFragment join = new JoinFragment();
            join.JoinType = Metadata.GetOperator(joinType);

            join.Left = VisitInputExpression(left.Expression, left.VariableName, left.VariableType);
            join.Left = WrapJoinInputIfNecessary(join.Left, false);

            join.Right = VisitInputExpression(right.Expression, right.VariableName, right.VariableType);
            join.Right = WrapJoinInputIfNecessary(join.Right, true);

            if (join.Right is SelectStatement)
            {
                SelectStatement select = join.Right as SelectStatement;
                if (select.IsWrapped)
                    select.Name = right.VariableName;
            }

            // now handle the ON case
            if (joinCondition != null)
                join.Condition = joinCondition.Accept(this);
            return join;
        }