我正在尝试访问ObjectContext
,以便能够使用WCF RIA / EF5增加CommandTimeout
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;
}
这不起作用。
目前,EF超时为30秒。
答案 0 :(得分:0)
我可能已经得到了:
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;
}