This documentation is archived and is not being maintained.

ObjectResult(Of T) Class

Represents the result of an ObjectQuery(Of T) as an enumerable collection of objects.

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

'Declaration
Public NotInheritable Class ObjectResult(Of T) _
	Inherits ObjectResult _
	Implements IEnumerable(Of T), IEnumerable
'Usage
Dim instance As ObjectResult(Of T)

Type Parameters

T

The entity type of the result.

This class implements IEnumerable(Of 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(Of 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(Of T) object.

Using advWorksContext As New AdventureWorksEntities

    Dim query As New ObjectQuery(Of Product)("Product", advWorksContext)

    ' Execute the query and get the ObjectQueryResult. 
    Dim queryResult As ObjectResult(Of Product) = query.Execute(MergeOption.AppendOnly)
    ' Iterate through the collection of Product items. 
    Dim result As Product
    For Each result In queryResult
        Console.WriteLine("{0}", result.Name)
    Next 
End Using

System.Object
  System.Data.Objects.ObjectResult
    System.Data.Objects.ObjectResult(Of T)

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
Show: