Repository Pattern Best Practice


When creating a repository, I pass the connection / unitofwork / ISession (nhibernate) that I want to use, in the constructor of the repository.The repository should not be responsible for creating the connection / ISession itself, since the repository has no knowledge of the context in which it will be used. You could also opt for using an inversion of control container like Castle or Spring.NET.

 

Source:

ADO.NET, the right way

http://stackoverflow.com/questions/25232361/do-i-need-open-and-close-methods-with-a-idisposable-class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s