Last post Apr 15, 2011 06:54 AM by r.rajeshkhunt
Apr 15, 2011 06:39 AM|DesmondCPX|LINK
I found that the tutorial in http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application made
use of the IDisposable interface for the UnitofWork class and an overrided dispose method in the controller.
However many other tutorials do not do this. Can someone please kindly explain to me if it is necessary to implement the IDisposable interface.
Thank you very much
Apr 15, 2011 06:54 AM|r.rajeshkhunt|LINK
It's not necessary but depends upon you how to endup with different parameters like performance etc.,
Here are some reason which may help you why it is :
When calling a class that implements the IDisposable interface, use the try/finally pattern to make sure that unmanaged resources are disposed of even if an exception
interrupts your application.
// Implement IDisposable.
// Do not make this method virtual.
// A derived class should not be able to override this method.
public void Dispose()
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.