Created
June 22, 2019 21:50
-
-
Save JwanKhalaf/c7597ac02ad7f9024c9b2b623f9bff24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var query = context.Artists.AsNoTracking() | |
.OrderBy(x => x.FirstName) | |
.Select(x => | |
new ArtistsResponse | |
{ | |
FirstName = x.FirstName, | |
LastName = x.LastName, | |
Slugs = x.Slugs.Select(s => new ArtistSlugResponse { Name = s.Name, IsPrimary = s.IsPrimary }).ToList(), | |
ImageId = x.Image == null ? 0 : x.Image.Id, | |
}); | |
var page = query.Paging(offset, limit) // do any filtering via `Where` here, before the paging clause, unless you want TotalCount to take filtering into consideration | |
.GroupBy(x => new { TotalCount = query.Count() }) | |
.First(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment