private CqlBlock JoinToCqlBlock(
            bool[] requiredSlots,
            CqlIdentifiers identifiers,
            ref int blockAliasNum,
            ref List <WithRelationship> withRelationships)
        {
            int             length1  = requiredSlots.Length;
            List <CqlBlock> children = new List <CqlBlock>();
            List <Tuple <QualifiedSlot, MemberPath> > tupleList = new List <Tuple <QualifiedSlot, MemberPath> >();

            foreach (CellTreeNode child in this.Children)
            {
                bool[] projectedSlots = child.GetProjectedSlots();
                OpCellTreeNode.AndWith(projectedSlots, requiredSlots);
                CqlBlock cqlBlock = child.ToCqlBlock(projectedSlots, identifiers, ref blockAliasNum, ref withRelationships);
                children.Add(cqlBlock);
                for (int length2 = projectedSlots.Length; length2 < cqlBlock.Slots.Count; ++length2)
                {
                    tupleList.Add(Tuple.Create <QualifiedSlot, MemberPath>(cqlBlock.QualifySlotWithBlockAlias(length2), cqlBlock.MemberPath(length2)));
                }
            }
            SlotInfo[] slotInfos = new SlotInfo[length1 + tupleList.Count];
            for (int slotNum = 0; slotNum < length1; ++slotNum)
            {
                SlotInfo joinSlotInfo = this.GetJoinSlotInfo(this.OpType, requiredSlots[slotNum], children, slotNum, identifiers);
                slotInfos[slotNum] = joinSlotInfo;
            }
            int index1 = 0;
            int index2 = length1;

            while (index2 < length1 + tupleList.Count)
            {
                slotInfos[index2] = new SlotInfo(true, true, (ProjectedSlot)tupleList[index1].Item1, tupleList[index1].Item2);
                ++index2;
                ++index1;
            }
            List <JoinCqlBlock.OnClause> onClauses = new List <JoinCqlBlock.OnClause>();

            for (int index3 = 1; index3 < children.Count; ++index3)
            {
                CqlBlock cqlBlock = children[index3];
                JoinCqlBlock.OnClause onClause = new JoinCqlBlock.OnClause();
                foreach (int keySlot in this.KeySlots)
                {
                    if (!this.ViewgenContext.Config.IsValidationEnabled && (!cqlBlock.IsProjected(keySlot) || !children[0].IsProjected(keySlot)))
                    {
                        ErrorLog errorLog = new ErrorLog();
                        errorLog.AddEntry(new ErrorLog.Record(ViewGenErrorCode.NoJoinKeyOrFKProvidedInMapping, Strings.Viewgen_NoJoinKeyOrFK, (IEnumerable <LeftCellWrapper>) this.ViewgenContext.AllWrappersForExtent, string.Empty));
                        ExceptionHelpers.ThrowMappingException(errorLog, this.ViewgenContext.Config);
                    }
                    QualifiedSlot leftSlot     = children[0].QualifySlotWithBlockAlias(keySlot);
                    QualifiedSlot rightSlot    = cqlBlock.QualifySlotWithBlockAlias(keySlot);
                    MemberPath    outputMember = slotInfos[keySlot].OutputMember;
                    onClause.Add(leftSlot, outputMember, rightSlot, outputMember);
                }
                onClauses.Add(onClause);
            }
            return((CqlBlock) new JoinCqlBlock(this.OpType, slotInfos, children, onClauses, identifiers, ++blockAliasNum));
        }
        private CqlBlock UnionToCqlBlock(
            bool[] requiredSlots,
            CqlIdentifiers identifiers,
            ref int blockAliasNum,
            ref List <WithRelationship> withRelationships)
        {
            List <CqlBlock> children = new List <CqlBlock>();
            List <Tuple <CqlBlock, SlotInfo> > tupleList = new List <Tuple <CqlBlock, SlotInfo> >();
            int length1 = requiredSlots.Length;

            foreach (CellTreeNode child in this.Children)
            {
                bool[] projectedSlots = child.GetProjectedSlots();
                OpCellTreeNode.AndWith(projectedSlots, requiredSlots);
                CqlBlock cqlBlock = child.ToCqlBlock(projectedSlots, identifiers, ref blockAliasNum, ref withRelationships);
                for (int length2 = projectedSlots.Length; length2 < cqlBlock.Slots.Count; ++length2)
                {
                    tupleList.Add(Tuple.Create <CqlBlock, SlotInfo>(cqlBlock, cqlBlock.Slots[length2]));
                }
                SlotInfo[] slotInfoArray = new SlotInfo[cqlBlock.Slots.Count];
                for (int slotNum = 0; slotNum < length1; ++slotNum)
                {
                    if (requiredSlots[slotNum] && !projectedSlots[slotNum])
                    {
                        if (this.IsBoolSlot(slotNum))
                        {
                            slotInfoArray[slotNum] = new SlotInfo(true, true, (ProjectedSlot) new BooleanProjectedSlot(BoolExpression.False, identifiers, this.SlotToBoolIndex(slotNum)), (MemberPath)null);
                        }
                        else
                        {
                            MemberPath outputMember = cqlBlock.MemberPath(slotNum);
                            slotInfoArray[slotNum] = new SlotInfo(true, true, (ProjectedSlot) new ConstantProjectedSlot(Constant.Null), outputMember);
                        }
                    }
                    else
                    {
                        slotInfoArray[slotNum] = cqlBlock.Slots[slotNum];
                    }
                }
                cqlBlock.Slots = new ReadOnlyCollection <SlotInfo>((IList <SlotInfo>)slotInfoArray);
                children.Add(cqlBlock);
            }
            if (tupleList.Count != 0)
            {
                foreach (CqlBlock cqlBlock in children)
                {
                    SlotInfo[] array = new SlotInfo[length1 + tupleList.Count];
                    cqlBlock.Slots.CopyTo(array, 0);
                    int index = length1;
                    foreach (Tuple <CqlBlock, SlotInfo> tuple in tupleList)
                    {
                        SlotInfo slotInfo = tuple.Item2;
                        array[index] = !tuple.Item1.Equals((object)cqlBlock) ? new SlotInfo(true, true, (ProjectedSlot) new ConstantProjectedSlot(Constant.Null), slotInfo.OutputMember) : new SlotInfo(true, true, slotInfo.SlotValue, slotInfo.OutputMember);
                        ++index;
                    }
                    cqlBlock.Slots = new ReadOnlyCollection <SlotInfo>((IList <SlotInfo>)array);
                }
            }
            SlotInfo[] slotInfos = new SlotInfo[length1 + tupleList.Count];
            CqlBlock   cqlBlock1 = children[0];

            for (int index = 0; index < length1; ++index)
            {
                SlotInfo slot         = cqlBlock1.Slots[index];
                bool     requiredSlot = requiredSlots[index];
                slotInfos[index] = new SlotInfo(requiredSlot, requiredSlot, slot.SlotValue, slot.OutputMember);
            }
            for (int index = length1; index < length1 + tupleList.Count; ++index)
            {
                SlotInfo slot = cqlBlock1.Slots[index];
                slotInfos[index] = new SlotInfo(true, true, slot.SlotValue, slot.OutputMember);
            }
            return((CqlBlock) new UnionCqlBlock(slotInfos, children, identifiers, ++blockAliasNum));
        }