我有一个存储库文件,我们在其中创建了实体类型的对象上下文,而不是 ObjectContext
类类型
public class ShopRepository : GenericRepository<tbl_Shop>
{
// Entity Framework context to the database
private DBEntities _contextObject;
public ShopRepository(DBEntities context)
: base(context)
{
this._contextObject = context;
}
}
我需要设置命令超时属性。 谁能帮帮我
最佳答案
您可以通过ObjectContext
的CommandTimeout
属性访问DbContext
命令超时,如下所示:
((IObjectContextAdapter)context).ObjectContext.CommandTimeout
所以如果你想在你的 ShopRepository
ctor 中设置它,只需这样做:
public ShopRepository(DBEntities context)
: base(context)
{
((IObjectContextAdapter)context).ObjectContext.CommandTimeout = your_value_here;
this._contextObject = context;
}
关于c# - 如何为实体对象上下文设置命令超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50001133/