5.4. Getting a Data Access Object

Once you get a DaoManager instance, you can use it to retrieve the DAO implementation by type (as specified in the dao.config file in the daoFactory section). Getting a DataAccess object is simply a matter of using the GetDao(type) method of a DaoManager instance (or the more concise indexer method DaoManager[type]) For example:

[C#]
IDaoManager daoManager = DaoManager.GetInstance("daoContextName"); 
// gets the dao of type 'ICategoryDao'
ICategoryDao categoryDao = daoManager.GetDao(typeof(ICategoryDao)) as ICategoryDao; 
// same thing, just using the indexer
IProductDao productDao = daoManager[typeof(IProductDao)] as IProductDao;