コード例 #1
0
        public override TResult Execute <TResult>(AzureQuery query)
        {
            if (EnumerableLinq.ShouldExecuteEnumerableLinqQuery(query))
            {
                return(EnumerableLinq.ExecuteEnumerableLinqQuery <TResult>(query));
            }
            if (!DoExecuteSearch(query))
            {
                return(ExecuteScalarMethod <TResult>(query));
            }
            if (typeof(TResult).IsGenericType && typeof(TResult).GetGenericTypeDefinition() == typeof(SearchResults <>))
            {
                var topDocs     = ExecuteQueryAgainstAzure(query);
                var type        = typeof(TResult).GetGenericArguments()[0];
                var methodInfo1 = GetType().GetMethod("ApplySearchMethods", BindingFlags.Instance | BindingFlags.NonPublic).MakeGenericMethod(type);
                var methodInfo2 = GetType().GetMethod("ApplyScalarMethods", BindingFlags.Instance | BindingFlags.NonPublic).MakeGenericMethod(typeof(TResult), type);
                var obj         = methodInfo1.Invoke(this, new object[2]
                {
                    query,
                    topDocs
                });
                return((TResult)methodInfo2.Invoke(this, new object[3]
                {
                    query,
                    obj,
                    topDocs
                }));
            }
            var topDocs1         = ExecuteQueryAgainstAzure(query);
            var processedResults = ApplySearchMethods <TResult>(query, topDocs1);

            return(ApplyScalarMethods <TResult, TResult>(query, processedResults, topDocs1));
        }
コード例 #2
0
        public override IEnumerable <TElement> FindElements <TElement>(AzureQuery query)
        {
            if (EnumerableLinq.ShouldExecuteEnumerableLinqQuery(query))
            {
                return(EnumerableLinq.ExecuteEnumerableLinqQuery <IEnumerable <TElement> >(query));
            }
            var searchHits = ExecuteQueryAgainstAzure(query);

            return(ApplySearchMethods <TElement>(query, searchHits).GetSearchResults());
        }
        public override TResult Execute <TResult>(SolrCompositeQuery compositeQuery)
        {
            if (EnumerableLinq.ShouldExecuteEnumerableLinqQuery(compositeQuery))
            {
                return(EnumerableLinq.ExecuteEnumerableLinqQuery <TResult>(compositeQuery));
            }
            if (typeof(TResult).IsGenericType &&
                typeof(TResult).GetGenericTypeDefinition() == typeof(SearchResults <>))
            {
                var resultType       = typeof(TResult).GetGenericArguments()[0];
                var solrQueryResults = this.Execute(compositeQuery, resultType);
                var type             = typeof(SolrSearchResults <>).MakeGenericType(resultType);
                var methodInfo       = this.GetType()
                                       .GetMethod("ApplyScalarMethods", BindingFlags.Instance | BindingFlags.NonPublic)
                                       .MakeGenericMethod(typeof(TResult), resultType);
                var selectMethod = GetSelectMethod(compositeQuery);

                var instance = ReflectionUtility.CreateInstance(type, (object)this._context, (object)solrQueryResults,
                                                                (object)selectMethod, (object)compositeQuery.ExecutionContexts,
                                                                (object)compositeQuery.VirtualFieldProcessors);
                return((TResult)methodInfo.Invoke(this, new object[3]
                {
                    compositeQuery,
                    instance,
                    solrQueryResults
                }));
            }

            compositeQuery.Methods.Add(new GetFacetsMethod());

            var solrQueryResults1 = this.Execute(compositeQuery, typeof(TResult));
            var selectMethod1     = GetSelectMethod(compositeQuery);
            var processedResults  = new SolrSearchResults <TResult>(this._context, solrQueryResults1, selectMethod1, compositeQuery.ExecutionContexts, compositeQuery.VirtualFieldProcessors);

            return(this.ApplyScalarMethods <TResult, TResult>(compositeQuery, processedResults, solrQueryResults1));
        }