Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq context object isn't registering as a type of System.IDisposable object

I'm trying to use my 'context' object in a using statement. It works on one project, but on another, I'm getting the following error.

'...': type used in a using statement must be implicitly convertible to 'System.IDisposable'

When I'm referring to the 'context' object, I'm referring to the object automatically created when you're working with LINQ to SQL.

The class I'm working within, implements another interface, could that be screwing up this context object?

using (TGDC context = new TGDC())
            {

            }

the word

using

has the red squigly line under it (error).

like image 678
Since_2008 Avatar asked Jul 19 '11 20:07

Since_2008


4 Answers

You should add a reference to System.Data.Linq. I suspect that's the issue.

like image 178
jason Avatar answered Oct 24 '22 00:10

jason


Or, if you are using Entity Framework, make sure you have a reference to System.Data.Entity and System.Data.Objects (C#: using / VB.NET: Imports).

like image 32
jamie Avatar answered Oct 23 '22 23:10

jamie


Add a reference to the EntityFramework.dll assembly that is referenced by the project that defines your EF context class.

like image 6
Christopher King Avatar answered Oct 23 '22 23:10

Christopher King


Add a reference to the EntityFramework assembly

like image 3
Rami Sarieddine Avatar answered Oct 24 '22 00:10

Rami Sarieddine