1

I have a repository file in which we have created object context of entity type and not of ObjectContext class type

public class ShopRepository : GenericRepository<tbl_Shop>
{
        // Entity Framework context to the database
        private DBEntities _contextObject;

        public ShopRepository(DBEntities context)
            : base(context)
        {
            this._contextObject = context;
        }
}

I need to set command timeout property. Can someone help me

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69
Keren Caelen
  • 1,466
  • 3
  • 17
  • 38

1 Answers1

3

You can access to the DbContext command timeout through the CommandTimeout property of your ObjectContext like below:

((IObjectContextAdapter)context).ObjectContext.CommandTimeout

So if you want to set it in your ShopRepository ctor just do this:

public ShopRepository(DBEntities context)
        : base(context)
{
     ((IObjectContextAdapter)context).ObjectContext.CommandTimeout = your_value_here;
     this._contextObject = context;
}
CodeNotFound
  • 22,153
  • 10
  • 68
  • 69