Ayende @ Wiki

The With.* set of classes has a single thing in common, they take a delegate and add functionality but handling pre/post and exceptional behavior.

Edit

With.Transaction

Will use the UnitOfWork to start a transaction, and automatically commit it if it was successful, or rollback if it failed. The usage is simply:

With.Transaction(delegate{
  Repository.Save(new Post("abc","foo"));
});


The main advantage here is, of course, the automatic rollback/commit.

Edit

With.Caching

This offers several methods that integrate into NHibernate query caching capabilities, and allow to cache all queries that are run until it is disposed delegate:

using(With.QueryCache())
{
  return Repository.FindAll(Where.Customer.Important == true);
}


Edit

With.PerformanceCounter

Allows you to very accurately time the length of time an operation took:

double duration = With.PerformanceCounter(delegate{
  DoSomething();
});


And now you can use the duration to do whatever you want, it is using the Windows performance counters, so it is very accurate.

ScrewTurn Wiki version 2.0 Beta. Some of the icons created by FamFamFam.