I've a significant deal of expertise programing with VB6, VB.Internet, C# the like and also have used ADO, then SubSonic and now i'm learning nHibernate since the majority of the prospective jobs I might opt for use nHibernate.

The truth is, I've been programming according to what I've been trained, read or arrived at understand as well as practice. Lately, someone via a spanner within the works coupled with me thinking. Until recently, I've been being able to access the database(s) from both core applcation and attached DLLs which i write.

What this persons stated finishes the following and therefore my question:

I can let you know that you simply may not do - an exterior class library should not have the database

Things I was attempting to do was to possess a shared/static class for nHibernate periods that may be consumed both in the worldwide scope from the application and from the dll. These kinds was to stay in a "core" DLL which all dlls and also the application reference. Like I stated I am learning nHibernate so it might not function as the way.

To express i am questioning my database access techniques is putting it gently.

Can anybody put me straight about this?


I guess searching at what's been said already, it is dependent how the database has been utilized. I'd tend not to put username/password qualifications etc hardcoded in almost any DLLs for just about any means.

More particularly, my totally with regards to NHibernate's periods. I've got a static class, an assistant class, that is known as at application start and also the new session will be produced and connected to the current context, within the situation of web programs, after which whenever I want the session I call "GetCurrentSession". This static class is incorporated in the "core" dll and may be utilized with any DLL etc that references. This behavior is supposed. My only real question is is ok? Must I do it one other way?

A few reasons could be

  1. Accessibility database, how can you cover off username/password
  2. discussing the DLL, a "bad" application may acquire your DLL and link to it to obtain access to your database.

Saying this, for those who have proper security on files, etc. i quickly might have thought utilizing a DLL would most likely be considered a reasonable approach to take.

Presuming the account information aren't saved directly within the DLL (but maybe passed as parameters, or passed like a complete connection object) this is not so bad.

The potential bad practice here may be being able to access exactly the same database for the similar purpose from different places - core application and DLL. This might get confusing rapidly to a different developer, unless of course the separation is obvious and logical.

Myself, I would attempt to move ALL (or just about all) data use of a DLL just for your purpose, then possess the serious application logic (or whenever possible) within the core application or another DLL.