0

I'm trying to access ObjectContext to be able to increase the CommandTimeout using WCF RIA / EF5

protected override MyEntities CreateDbContext()
{
    var dbContext = base.CreateDbContext();

    // returns a null ref
    // Get the ObjectContext related to this DbContext
    var objectContext = (this as IObjectContextAdapter).ObjectContext;            

    objectContext.CommandTimeout = 120;
    return dbContext;
}

This doesn't work.

Currently the EF timeout is 30secs.

Dave Mateer
  • 6,588
  • 15
  • 76
  • 125
  • Have you tried this: http://stackoverflow.com/questions/8059900/convert-dbcontext-to-objectcontext-for-use-with-gridview – ErikEJ Jul 01 '13 at 10:51

1 Answers1

0

I may have got it with:

 protected override MyEntities CreateDbContext()
        {
            var dbContext = base.CreateDbContext();

            // Get the ObjectContext related to this DbContext
            var objectContext = (dbContext as IObjectContextAdapter).ObjectContext;

            // Sets the command timeout for all the commands
            objectContext.CommandTimeout = 240;

            return dbContext;
        }
Dave Mateer
  • 6,588
  • 15
  • 76
  • 125