In C#, I have the following extremely verbose syntax for pulling a simple list of items from a database:
if (malls == null)
{
lock (_lock)
{
if (malls == null)
{
using (var session = NhibernateHelper.OpenSession())
{
malls = session.CreateCriteria<Mall>()
.AddOrder(Order.Asc("Name")).List<Mall>();
CacheManager.Set(CACHE_KEY, malls, TimeSpan.FromMinutes(CACHE_DURATION));
}
}
}
}
I'm aware of the benefits of double checked locking and I strongly support its use, but it seems incredibly verbose. Can you recommend any syntax shortcuts or styles that might clean it up a bit?