RavenDB: Learning from RacoonBlog, Paging.

ASP.NET MVC,RavenDB 18 January 2012 | 0 Comments

In this series of blog posts I’ll be looking at a few gems I’ve found in the Racoon Blog source code that have helped me become a better code and feel happier about my codebase.

One thing I find really helpful when trying to improve my coding skills is reading other (smarter) peoples code. Specifically when learning RavenDB I have found Ayende’s blog engine Racoon Blog to contain a wealth of hints, tricks and general good practice with RavenDB and ASP.NET MVC generally.

The first gem from RacoonBlog I found is paging.

With LINQ queries you page by doing the following:

query.Take(50).Skip(50)

I have been doing this myself until I came across this in the Racoon Blog source code:

query.Paging(CurrentPage, DefaultPage, PageSize)

What…

Ayende has written this helper to help remove the duplidate Take() and Skip() statements in his query.

As a side note, CurrentPage, DefaultPage and PageSize are defined on the base controller. Having these defined in one place also reduces duplicate code!

Leave a Reply