Last active
February 3, 2019 16:57
-
-
Save jamesmundy/e2c83a698cfc5444ed022ad71638c97b to your computer and use it in GitHub Desktop.
My code to search Azure Search and the records I then get from the database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Task<PagedList<BoatDto>> Find(BoatCriteria criteria) | |
{ | |
return Adapter.Connect() | |
.CallAsync(async provider => | |
{ | |
var results = await _searchService.SearchBoatsAsync(criteria.Filter, | |
criteria.PageSize * criteria.PageNumber); | |
var unorderedResults = await provider.Boats() | |
.Where(b => results.Contains(b.Id)) | |
.Select(BoatMappings.Select()) | |
.OrderBy(x => x.Name) | |
.ToPagedListAsync(c => c, criteria); | |
var orderedResults = unorderedResults.Items.OrderBy(b => results.IndexOf(b.Id)) | |
.ToList(); | |
return orderedResults; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment