This documentation is archived and is not being maintained.

ObjectResult<T> Class

Represents the result of an ObjectQuery<T> as an enumerable collection of objects.

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

public sealed class ObjectResult<T> : ObjectResult, 
	IEnumerable<T>, IEnumerable

Type Parameters


The entity type of the result.

This class implements IEnumerable<T> and IDisposable. Instances of this class are returned from the Execute method and from the GetEnumerator method.

The example in this topic is based on the Adventure Works Sales Model, which was generated by the Entity Data Model Wizard.

The following example returns an ObjectResult<T> from the Execute method. Then it gets an enumerator and iterates through the query results. At the end, it releases the enumerator and the ObjectResult<T> object.

using (AdventureWorksEntities advWorksContext =
    new AdventureWorksEntities())
    ObjectQuery<Product> query = 
        new ObjectQuery<Product>("Product", advWorksContext);

    // Execute the query and get the ObjectQueryResult.
    ObjectResult<Product> queryResult = query.Execute(MergeOption.AppendOnly);
    // Iterate through the collection of Product items. 
    foreach (Product result in queryResult)
        Console.WriteLine("{0}", result.Name);


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5 SP1