Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created September 20, 2012 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/3755895 to your computer and use it in GitHub Desktop.
Save jbogard/3755895 to your computer and use it in GitHub Desktop.
public ActionResult Archive(int year, int? month, int? day)
{
RavenQueryStatistics stats;
var postsQuery = RavenSession.Query<Post>()
.Include(x => x.AuthorId)
.Statistics(out stats)
.WhereIsPublicPost()
.Where(post => post.PublishAt.Year == year);
if (month != null)
postsQuery = postsQuery.Where(post => post.PublishAt.Month == month.Value);
if (day != null)
postsQuery = postsQuery.Where(post => post.PublishAt.Day == day.Value);
var posts =
postsQuery.OrderByDescending(post => post.PublishAt)
.Paging(CurrentPage, DefaultPage, PageSize)
.ToList();
return ListView(stats.TotalResults, posts);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment