Using DAO's or static methods in Domain Object with nHibernate
- by mickyjtwin
I am using nHibernate for the first time, and after alot of reading/researching, plus looking at other projects done with nHibernate, have seen a couple of implementation practices. I am looking for opinions about which would be best to use and why.
Essentially the two methods are as follows:
Using Data Access Objects and a DAO Factory.
Example usage:
INotificationListDAO nListDAO = NHDaoFactory.GetNotificationListDAO();
NotificationList list = nListDAO.GetByListID("");
Use Static methods in the Domain Object.
Example usage:
NotificationList list = NotificationList.GetByListID("");
NHHelper.Session.Get(id);
NHHelper.Session basically calls the NHibernateSessionManager.Instace.GetSessionFrom("").
While both look similar, it is more to do with best practice. From what I understand, the first option is more so if you are developing enterprise level applications, where my requirements are more for mid-range websites.