Ejemplo n.º 1
0
        /// <summary>
        /// Realize the ResultsViewProps for the subquery selected view id
        /// </summary>
        /// <returns></returns>

        public ResultsViewProps RealizeSubQueryView()
        {
            ResultsViewProps activeView;

            if (SubQuerySelectedView != null)
            {
                return(SubQuerySelectedView);
            }

            if (SubQuery == null)             // need to get the subquery
            {
                if (RealizeSubQuery() == null)
                {
                    return(null);
                }
            }

            List <ResultsViewProps> views = SubQuery.GetResultsViews(out activeView);            // get the list of views and the "active" view if defined

            if (views == null || views.Count == 0)
            {
                return(null);
            }

            if (Lex.IsDefined(SubQuerySelectedViewId))             // look for the selected view
            {
                foreach (ResultsViewProps vp in views)
                {
                    if (vp.Id == SubQuerySelectedViewId)
                    {
                        SubQuerySelectedView   = vp;
                        SubQuerySelectedViewId = vp.Id;
                        return(vp);
                    }
                }
            }

            // If selected view not defined or not found then use the last view in the query by default

            if (activeView == null)
            {
                activeView = views[views.Count - 1];                                 // last view
            }
            SubQuerySelectedViewId = activeView.Id;
            SubQuerySelectedView   = activeView;
            return(activeView);
        }