2
using(ctx e = new ctx())
{
   var pkg = from clPkg in e.PkgCoilPkgs.Include("PkgBand")
                               .Where(c2 => c2.PkgId == PkgID)
                               select new PkgCoilcls
                               {
                                  PkgCoilPkg = clPkg,
                               };
  return pkg.FirstOrDefault();
}

PkgBand is a foreign key table and lazy Loading enabled is set to true

statement: var pkgBand = PkgCoilPkg.PkgBand.Name;

throws

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

Even though I am using Include("PkgBand") to load, Why I am getting this error?

3
  • And what happens if you don't use that projection? Commented Jan 31, 2011 at 6:20
  • are you sure you have the context instance? check with a brackpoint if e is null or not. Commented Jan 31, 2011 at 6:22
  • Thanks, I fixed it using Projection ; select new { PkgCoilPkg, PkgCoilPkg.PkgBand }; Here is more info: stackoverflow.com/questions/4474951/… Commented Jan 31, 2011 at 15:50

1 Answer 1

1

Thanks, I fixed it using Projection ; select new { PkgCoilPkg, PkgCoilPkg.PkgBand }; Here is more info: Entity Framework Include() is not working

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.