Export (0) Print
Expand All

ObjectContext.CommandTimeout Property

Gets or sets the timeout value, in seconds, for all object context operations. A null value indicates that the default value of the underlying provider will be used.

Namespace:  System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public Nullable<int> CommandTimeout { get; set; }

Property Value

Type: System.Nullable<Int32>
An Int32 value that is the timeout value, in seconds.

ExceptionCondition
ArgumentException

The timeout value is less than 0.

The default timeout for object queries and the SaveChanges operation is defined by the underlying connection provider. However, you can override this default timeout value by using the CommandTimeout property on the ObjectContext, as shown in the following example.

// Specify a timeout for queries in this context, in seconds.
context.CommandTimeout = 120;

Do this when you have a complex query or when other performance issues cause queries or calls to SaveChanges to time out frequently.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft