Skip to content

Instantly share code, notes, and snippets.

@kristofclaes
Created June 5, 2011 08:47
Show Gist options
  • Save kristofclaes/1008800 to your computer and use it in GitHub Desktop.
Save kristofclaes/1008800 to your computer and use it in GitHub Desktop.
Another way of retrieving next and previous records with Simple.Data
// 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