I'm using db4o. My question is about best practices of how one should open and close the database in an ASP.NET web form?
I guess opening and closing the database before and after each save or update, is not the best practice because of the overhead this implies, lost of indexes, etc.
I have a "System" class that uses Singleton pattern, and it's the only class that connects to the database. On the constructor, I open the database, but I'm not sure when to close it, or even when to commit.
Should I commit EVERY TIME after a save if success and rollback if error?
When should I close or dispose the database? Should I implement IDisposable interface? Should I add a Destructor to my "System" class?