private static ViewGenResults GenerateViewsFromCells(
            List <Cell> cells,
            ConfigViewGenerator config,
            CqlIdentifiers identifiers,
            EntityContainerMapping containerMapping)
        {
            EntityContainer storageEntityContainer = containerMapping.StorageEntityContainer;
            ViewGenResults  viewGenResults         = new ViewGenResults();
            ErrorLog        errorLog1 = ViewgenGatekeeper.EnsureAllCSpaceContainerSetsAreMapped((IEnumerable <Cell>)cells, containerMapping);

            if (errorLog1.Count > 0)
            {
                viewGenResults.AddErrors(errorLog1);
                Helpers.StringTraceLine(viewGenResults.ErrorsToString());
                return(viewGenResults);
            }
            List <ForeignConstraint> foreignConstraints = ForeignConstraint.GetForeignConstraints(storageEntityContainer);

            foreach (Set <Cell> groupRelatedCell in new CellPartitioner((IEnumerable <Cell>)cells, (IEnumerable <ForeignConstraint>)foreignConstraints).GroupRelatedCells())
            {
                ViewGenerator viewGenerator = (ViewGenerator)null;
                ErrorLog      errorLog2     = new ErrorLog();
                try
                {
                    viewGenerator = new ViewGenerator(groupRelatedCell, config, foreignConstraints, containerMapping);
                }
                catch (InternalMappingException ex)
                {
                    errorLog2 = ex.ErrorLog;
                }
                if (errorLog2.Count == 0)
                {
                    errorLog2 = viewGenerator.GenerateAllBidirectionalViews(viewGenResults.Views, identifiers);
                }
                if (errorLog2.Count != 0)
                {
                    viewGenResults.AddErrors(errorLog2);
                }
            }
            return(viewGenResults);
        }
        internal static ViewGenResults GenerateTypeSpecificQueryView(
            EntityContainerMapping containerMapping,
            ConfigViewGenerator config,
            EntitySetBase entity,
            EntityTypeBase type,
            bool includeSubtypes,
            out bool success)
        {
            if (config.IsNormalTracing)
            {
                Helpers.StringTraceLine("");
                Helpers.StringTraceLine("<<<<<<<< Generating Query View for Entity [" + entity.Name + "] OfType" + (includeSubtypes ? "" : "Only") + "(" + type.Name + ") >>>>>>>");
            }
            if (containerMapping.GetEntitySetMapping(entity.Name).QueryView != null)
            {
                success = false;
                return((ViewGenResults)null);
            }
            InputForComputingCellGroups args       = new InputForComputingCellGroups(containerMapping, config);
            OutputFromComputeCellGroups cellgroups = containerMapping.GetCellgroups(args);

            success = cellgroups.Success;
            if (!success)
            {
                return((ViewGenResults)null);
            }
            List <ForeignConstraint> foreignKeyConstraints = cellgroups.ForeignKeyConstraints;
            List <Set <Cell> >       list = cellgroups.CellGroups.Select <Set <Cell>, Set <Cell> >((Func <Set <Cell>, Set <Cell> >)(setOfcells => new Set <Cell>(setOfcells.Select <Cell, Cell>((Func <Cell, Cell>)(cell => new Cell(cell)))))).ToList <Set <Cell> >();
            List <Cell>    cells          = cellgroups.Cells;
            CqlIdentifiers identifiers    = cellgroups.Identifiers;
            ViewGenResults viewGenResults = new ViewGenResults();
            ErrorLog       errorLog1      = ViewgenGatekeeper.EnsureAllCSpaceContainerSetsAreMapped((IEnumerable <Cell>)cells, containerMapping);

            if (errorLog1.Count > 0)
            {
                viewGenResults.AddErrors(errorLog1);
                Helpers.StringTraceLine(viewGenResults.ErrorsToString());
                success = true;
                return(viewGenResults);
            }
            foreach (Set <Cell> set in list)
            {
                if (ViewgenGatekeeper.DoesCellGroupContainEntitySet(set, entity))
                {
                    ViewGenerator viewGenerator = (ViewGenerator)null;
                    ErrorLog      errorLog2     = new ErrorLog();
                    try
                    {
                        viewGenerator = new ViewGenerator(set, config, foreignKeyConstraints, containerMapping);
                    }
                    catch (InternalMappingException ex)
                    {
                        errorLog2 = ex.ErrorLog;
                    }
                    if (errorLog2.Count <= 0)
                    {
                        ViewGenMode mode = includeSubtypes ? ViewGenMode.OfTypeViews : ViewGenMode.OfTypeOnlyViews;
                        ErrorLog    viewForSingleExtent = viewGenerator.GenerateQueryViewForSingleExtent(viewGenResults.Views, identifiers, entity, type, mode);
                        if (viewForSingleExtent.Count != 0)
                        {
                            viewGenResults.AddErrors(viewForSingleExtent);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            success = true;
            return(viewGenResults);
        }