MaxPetya
MaxPetya

Reputation: 61

"The ObjectContext instance has been disposed and can no longer be used for operations that require a connection"

have small problem here. heres the code:

 using (LINKSEntitiesMaster LE = new LINKSEntitiesMaster())
            {

                Cache["ALLDB"] = LE;                   

            }

 internal void FilterDB(string ParentPageTitle, string ButtonName)


    {

        var ALLdb = (LINKSEntitiesMaster)Cache["ALLDB"];


        var x = ALLdb.MainTables.Where(s => s.Language == ParentPageTitle && s.ButtonName == ButtonName).Select(w => w.AllLinks).ToList();



        Links.DataSource = ALLdb;
        Links.DataBind();


}

the error is in the topic. i save the filterd DB to a list,cant see why the connection closed...?

i been searching but could not fined an answer.

Upvotes: 0

Views: 238

Answers (1)

Brian Maupin
Brian Maupin

Reputation: 745

Connection is likely being closed since LINKSEntitiesMaster LE = new LINKSEntitiesMaster() is wrapped in a using statement. Once you code goes outside the using scope LINKSEntitiesMaster gets disposed.

Upvotes: 1

Related Questions