I know this question has been asked several times before, but I couldn't get the answer I was looking for. So, I've implemented the Repository (generic) and UOW pattern, so I can access my DB using EF. Here's part of the UnitOfWork class:
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
entities.Dispose();
}
}
this.disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
The question is: Who is calling the void Dispose method?? I've seen no example of the usage of that method.
this it the upper part of the Unit Of Work class:
private BDEntities entities = null;
public UnitOfWork()
{
if (entities == null)
{
entities = new BDEntities();
}
}
Is this right? should I use "Using"? and if yes, than why do I need the Dispose method?
Can you give me an example of a proper and simple usage?
Thank you, Rotem