ObjectContext.Translate(Of TEntity) Method (DbDataReader, String, MergeOption)

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Translates a DbDataReader that contains rows of entity data to objects of the requested entity type, in a specific entity set, and with the specified merge option.

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

Public Function Translate(Of TEntity) (
	reader As DbDataReader,
	entitySetName As String,
	mergeOption As MergeOption
) As ObjectResult(Of TEntity)

Parameters

reader
Type: System.Data.Common.DbDataReader

The DbDataReader that contains entity data to translate into entity objects.

entitySetName
Type: System.String

The entity set of the TResult type.

mergeOption
Type: System.Data.Objects.MergeOption

The MergeOption to use when translated objects are added to the object context. The default is AppendOnly.

Return Value

Type: System.Data.Objects.ObjectResult(Of TEntity)

An enumeration of objects of type TResult.

Type Parameters

TResult

The entity type of the data in the DbDataReader.

Exception Condition
ArgumentNullException

When reader is null.

ArgumentOutOfRangeException

When the supplied mergeOption is not a valid MergeOption value.

InvalidOperationException

When the supplied entitySetName is not a valid entity set for the TResult type.

The Translate(Of TElement) method is used to translate entity data from a DbDataReader into objects of the requested type. This process is performed automatically when an ObjectQuery(Of T) is executed to return entity data. The Translate(Of TElement) method enables you to execute a standard ADO.NET query against a data source and translate the returned data rows into entity objects.

The supplied DbDataReader must contain data that maps to the requested entity type.

For more information, see:

Directly Executing Store Commands and

How to: Directly Execute Commands Against the Data Source

.NET Framework
Available since 4.0
Return to top
Show: