In the previous hour I wrote a real simple web application with the purpose of CRUD (Create, Read, Update and Delete) log entries. When you use ASP.NET and ADO.NET that would typically take a couple of hours. First you would have to create the database scheme then you would have to write the business logic and finally you need to create the pages.

However I decided to leverage the power of some components of the Castle project [1]: Castle MonoRail [2] and Castle ActiveRecord [3]. Castle Monorail is a MVC (Model View Controller) framework and Castle ActiveRecord is a framework based on the active record[4] pattern. The components integrate very nicely as you will see.

First I created the log entry active record class which is a simple POCO (Plain Old CLR Object), derived it from ActiveRecordBase and decorated its properties with the proper ActiveRecord attributes. That is it for the database logic, fast is it not?

Then I created the controller for the log entries. I simply created a class, derived it from Controller and added the Scaffolding attribute to it. That took me about a minute to implement.

Finally I needed to do some plumbing: configuration and initialization. That is all. I now have an working application which allows me to list (with pagination!), view, create, update and delete log entries. The design is awful but it good enough for its purpose.

Castle project supports this out of the box which is amazing in my opinion. You can download a sample application here.

Sources

[1] Castle Project
[2] Castle MonoRail
[3] Castle ActiveRecord
[4] Active Record Pattern