Print Page | Close Window

EFContextProvider<T> should implement IDisposable

Printed From: IdeaBlade
Category: Breeze
Forum Name: Community Forum
Forum Discription: Build rich JavaScript apps using techniques you already know
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3699
Printed Date: 28-Feb-2020 at 11:53am


Topic: EFContextProvider<T> should implement IDisposable
Posted By: pawel
Subject: EFContextProvider<T> should implement IDisposable
Date Posted: 08-Oct-2012 at 7:34am
EFContextProvider<T> instantiates DbContext which implements IDisposable, but EFContextProvider<T> doesn't implement IDisposable. I think it should.



Replies:
Posted By: jtraband
Date Posted: 08-Oct-2012 at 9:38am
Agreed, this should probably be fixed in one of the next few releases.

If this worries you for right now, you can directly access the Context object from the EFContextProvider instance, cast it to either an ObjectContext or a DbContext and call dispose on it.

As a side note: 

From the Albarahi "c# 4.0 in a nutshell" book:

 > Although DataContext/ObjectContext implement IDisposable, you can (in general) get away without disposing instances. Disposing forces the context’s connection to dispose—but this is usually unnecessary because L2S and EF close connections automatically whenever you finish retrieving results from a query <<





Print Page | Close Window