I am using nHibernate. My classes are POCO, that map 1:1 with my database tables. I created a IGenericDAO -> GenericDAO that does all my basic CRUD. (repository) Each table has a DAO class, so:
public class UserDAO : GenericDAO
Any table specific queries will go in the tableDAO class.
I then have a factory, IDAOFactory.
public class NHibernateDAOFactory : IDAOFactory
{
public static UserDAO GetUserDAO()
{
return new UserDAO();
}
}
Possible improvement: 1. Just so my web application isn't littered with:
IDAOFactory dbFactory = new NHibernateDAOFactory();
I was thinking of creating:
public class DAOFactoryFactory
{
public static IDAOFactory Load()
{
return new NHibernateDAOFactory();
}
}
This way I have a single point of change in case I need to swap database layers. (i.e. switch between linq2sql and nhibernate, but not sure that is possible in reality)
Any suggestions/pointers on how to improve this, or is this pretty much solid?