In order for our Data Access Objects to be effective for our use, they need to contain a few basic methods. In general, our DAOs will be responsible for all of the CRUD (Create, Retrieve, Update, and Delete) operations, so we will need to create methods to handle those operations.
We should add a local
ISession
variable called Session
to allow easy access from our class. This gives us a single place to update in our class, should we decide to change the way we are handling sessions.
private ISession Session { get { return SessionFactory.OpenSession(); } }
The VB.NET code looks almost the same:
Private ReadOnly Property Session() As ISession Get Return SessionFactory.OpenSession() End Get End Property
In order to make the interaction with our Data Access Object feel more natural to use, we need to do one more thing—add a Singleton object. Basically, we will create a property, called Instance
, that will allow us to call the methods on our Data Access Object...