Example #1
0
        /// <summary>
        /// Searches the source.
        /// </summary>
        /// <param name="searchCriteria">The search criteria.</param>
        /// <param name="includedProperties">The included properties.</param>
        /// <returns>Task&lt;SearchResults&lt;TTargetEntity, SearchCriteria&gt;&gt;.</returns>
        public virtual async Task <SearchResults <TTargetEntity, SearchCriteria> > SearchSource(SearchCriteria searchCriteria, IEnumerable <string> includedProperties = null)
        {
            searchCriteria.ContextBag["HA"] = false;
            var response = await ExecuteSearch(searchCriteria, includedProperties);

            var results = response?.Data ?? new List <TTargetEntity>();

            //TODO: search does not return metadata....what should we do here?
            // if we got back less than we asked for, then there are no more results, otherwise, pretend there is one more
            var totalRecords = results.Count < searchCriteria.PageSize
                ? results.Count
                : results.Count + 1;

            return(_resultsBuilder.Build(results, searchCriteria, totalRecords));
        }
 /// <summary>
 /// Searches the content of the result.
 /// </summary>
 /// <param name="results">The results.</param>
 /// <param name="criteria">The criteria.</param>
 /// <param name="totalRecords">The total records.</param>
 /// <returns>SearchResults&lt;T, C&gt;.</returns>
 protected virtual SearchResults <TSummery, TCriteria> SearchResultContent(List <TSummery> results, TCriteria criteria, int totalRecords)
 {
     return(_resultsBuilder.Build(results, criteria, totalRecords));
 }