-
-
Save ToJans/1014127 to your computer and use it in GitHub Desktop.
Retrieving next and previous records with Simple.Data
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
// Checked blog at http://blog.markrendle.net/2011/05/23/simple-data-0-6-5/ | |
// and code at https://github.com/markrendle/Simple.Data/blob/master/Simple.Data/SimpleQuery.cs | |
int? previousPhotoId = DB.Photos.Query() | |
.Select(DB.Photos.Id) | |
.Where(DB.Photos.Published == true && DB.Photos.DatePublished < currentPhoto.DatePublished.Value) | |
.OrderByDatePublishedDescending() | |
.ToScalarOrDefault<int?>(); | |
int? nextPhotoId = DB.Photos.Query() | |
.Select(DB.Photos.Id) | |
.Where(DB.Photos.Published == true && DB.Photos.DatePublished > currentPhoto.DatePublished.Value) | |
.OrderByDatePublishedAscending() | |
.ToScalarOrDefault<int?>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment