c# - Implement IDisposable in abstract class -


this question has answer here:

i have following abstract class , need implement idisposable make sure dbcontent disposed time properly.

public abstract class datarepositorybase<t> : datarepositorybase<t, maindbcontext>     t : class, iidentifiableentity, new() {  } 

what best way achieve that?

please note: i'm aware on how use idisposable in concrete classes implementation of functionality in abstract class - not clear

i take implementation provided in answer:

proper use of idisposable interface

and in derived types override dispose(bool disposing) method if derived type needs dispose of stuff, remembering call base. if doesn't need to, nothing base implementation.

make sure makes sense expose need call dispose on type's public contract, sign of leaked abstraction (though not always).

this @ least start.


Comments