/// <summary>
        /// Create a <see cref="Api.Domain.Query"/> object that will be used for Querying.
        /// </summary>
        /// <param name="queryModel">Expression Tree of LINQ Query</param>
        /// <param name="settings">Defines how to handle query results</param>
        /// <returns>Query to Invoke</returns>
        internal Query GenerateQuery(QueryModel queryModel, out QueryResultsSettings settings)
        {
            var visitor = new InfluxDBQueryVisitor(_bucket, _memberResolver);

            visitor.VisitQueryModel(queryModel);

            settings = new QueryResultsSettings(queryModel);
            return(visitor.GenerateQuery());
        }
        protected override Expression VisitSubQuery(SubQueryExpression subQuery)
        {
            if (subQuery.QueryModel.ResultOperators.All(p => p is AnyResultOperator))
            {
                var query = new QueryAggregator();

                var modelVisitor = new InfluxDBQueryVisitor(_context.Clone(query));
                modelVisitor.VisitQueryModel(subQuery.QueryModel);

                _context.QueryAggregator.AddSubQueries(query);

                return(subQuery);
            }

            return(base.VisitSubQuery(subQuery));
        }