ObjectContext::Translate<TEntity> Method (DbDataReader^, String^, MergeOption)

.NET Framework (current version)
 

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:
generic<typename TEntity>
ObjectResult<TEntity>^ Translate(
	DbDataReader^ reader,
	String^ entitySetName,
	MergeOption mergeOption
)

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<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<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<T> is executed to return entity data. The Translate<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: