Entity Framework - what is the current command timeout value

前端 未结 5 1831
南方客
南方客 2021-01-17 07:49

I\'m using Entity Framework 5 and I wish to know the command timeout value.

In order to do so, I cast the dbContext object to an ObjectContext

5条回答
  •  无人共我
    2021-01-17 07:57

    This is how I do it.

    ObjectContext objectContext = ((IObjectContextAdapter)dbContext).ObjectContext
    int commandTimeout = objectContext.CommandTimeout 
        ?? objectContext.Connection.CreateCommand().CommandTimeout;
    

提交回复
热议问题