コード例 #1
0
        /// <summary>
        /// Gets all source aliases.
        /// </summary>
        /// <param name="node">
        /// The node.
        /// </param>
        /// <returns>
        /// The aliases.
        /// </returns>
        public static IEnumerable <string> GetAllSources(Node node)
        {
            var retriever = new SourceAliasesRetriever();

            retriever.Visit(node);

            return(retriever.aliases);
        }
コード例 #2
0
        private SelectQueryPlan CreateSelectQueryPlan([NotNull] SelectFromStatement node)
        {
            var usedFields      = new HashSet <IField>();
            var wildcardAliases = new HashSet <string>();
            var fieldNames      = node.Expressions.Select(f => f.Expression is WildcardSqlExpression ? "*" : f.Alias);
            var valueFactory    = this.GetValueFactory(node.Expressions, usedFields, wildcardAliases, SourceAliasesRetriever.GetAllSources(node));
            var sourceFactory   = this.GetSourceFactory(node.Source);

            var query = new MultiPartQuery
            {
                Fields             = usedFields,
                FilterExpression   = this.data.ConvertToLinqExpression(node.Where, false),
                OrderByExpressions = node.Orders.Select(o => new OrderByExpression(this.data.ConvertToLinqExpression(o.Expression, false), o.Ascending)),
                WildcardAliases    = wildcardAliases,
            };

            var func      = valueFactory as ValueFactory;
            var queryPlan = func != null
                                ? new SelectQueryPlan(sourceFactory, query, fieldNames, func)
                                : new SelectQueryPlan(sourceFactory, query, fieldNames, (AsyncValueFactory)valueFactory);

            return(queryPlan);
        }