Does my UoW class need to implement IDisposable if my BaseUow already implements it?

144 views Asked by At

I have created a base class for my Unit of Work called BaseUoW that inherits IDisposable like so:

public class BaseUoW : IDisposable
{
}

My question is... If i create class called UserUoW for example that inherits my BaseUoW does the UserUoW need to implement IDisposable or will it be handled by my BaseUow

public class BaseUoW : IBaseUoW
{
}

Or

public class BaseUoW : IBaseUoW, IDisposable
{
}

IBaseUoW

public interface IBaseUoW
{
    virtual void Dispose(bool disposing);
    void Commit();
}
1

There are 1 answers

0
sstan On BEST ANSWER

You don't need to add it to the class declaration, unless you want to make it explicit for readability.

However, what you may need, is to add a protected virtual void Dispose(bool disposing){ method override to perform the child class' clean up tasks if there are any.

See here for more information on the proper pattern to follow.

EDIT: As pointed out in the comments, this is only if you are truly extending from your base BaseUoW class. Because your "pictures" show it implementing some other interface, not extending your base class in question.