1
votes

I am extending LINQ to SQL entity classes using partial classes, and I'm wondering how to best reset some properties on the entity objects to their default state.

My partial classes uses no unmanaged recourses. And as far as I can tell; neither does the LINQ to SQL entity classes. So I'm thinking that I'll implement IDisposable and handle the resetting of properties inside of Dispose().

  • What are your thoughts on this approach?
  • And would you set before mentioned properties to null or something else?
1

1 Answers

2
votes

For better or worse, IDisposable is almost universally associated with finishing with a resource rather than reseting it. This sounds like an odd use to me. I would just create a Reset() method - or just create a new instance when you need to. What's the purpose of this? What are you trying to achieve?

As for "suppress[ing] the instance on the GC" - what exactly do you mean? If you're talking about a finalizer, I'd think very carefully before adding a finalizer - it's very rarely the right way to go.