Link to home
Start Free TrialLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Question about disposing my Entity Model

I create my RDDBDataStore very very often and want to be certain I am disposing it correctly.

In this code, RDDB is the object created for me by the Entity Framework (4.0) with the RDDB.edmx file.

Is this code correct to dispose of it? I set a breakpoint on Dispose() but it never reach it. How can I test this?  Is this correct?

Thanks,
newbieweb
public RDDBDataStore()
        {
            rddbEntities = new RDDB();
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected void Dispose(bool disposing)
        {
            if (disposing)
            {
                rddbEntities.Dispose();
                GC.SuppressFinalize(this);
            }
        }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of curiouswebster

ASKER

Thanks!