Sometimes a refactor can be painful, but there is a light at the end of the tunnel, especially when you know the refactor will be a good move.
I really enjoyed working with Spring.NET but decided to shift to a simplier* model (Sharp Architecture). A positive is that my code was separated well enough that the impact was minor. (when I say ‘simplier’ – most that I’m only using a small subset of Spring.NET – NHibernate session management/Transactional management/Dao injection into my controllers)
One move led to another, and I made the jump to NHibernate 2.0. While I was frustrated at being able to find the installer for NHQG 1.9 (there is one for 1.8 with NH 1.2) – I realized that the NHibernate direction is moving to NHibernate.Linq… so, hey, let’s try it out.
ICriteria crit = Session.CreateCriteria(typeof(EmployeeQuerySet)) .Add(Expression.Like("LastName", lastName, MatchMode.Start)); return crit.List<EmployeeQuerySet>();
return this.FindAll(Where.EmployeeQuerySet.LastName.Like(lastName, MatchMode.Start), OrderBy.EmployeeQuerySet.LastName.Asc);
var query = from emp in Session.Linq<EmployeeQuerySet>() where emp.LastName.StartsWith(lastName) orderby emp.LastName ascending select emp;
I personally like the Linq syntax because I’ve been using it since it was available to replace all my collection delegate calls.
So far so good on the refactoring… 🙂
(By the way, I really haven’t seen the value of something like EF or Linq to SQL when I have the power of NHibernate and NHibernate.Linq)