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

1 Answer 1

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;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.