Created
June 5, 2011 08:47
-
-
Save kristofclaes/1008800 to your computer and use it in GitHub Desktop.
Another way of 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
// This also works, but again, it doesn't look very elegant | |
int? previousId; | |
try | |
{ | |
previousId = DB.Photos | |
.FindAll(DB.Photos.Published == true && DB.Photos.DatePublished < currentPhoto.DatePublished.Value) | |
.OrderByDatePublishedDescending() | |
.Take(1) | |
.Select(DB.Photos.Id) | |
.First() | |
.Id; | |
} | |
catch | |
{ | |
previousId = null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment