ObjectContext.Translate 方法

定義

多載

Translate<TElement>(DbDataReader)

將包含實體資料之資料列的 DbDataReader,轉譯成所要求的實體型別。Translates a DbDataReader that contains rows of entity data to objects of the requested entity type.

Translate<TEntity>(DbDataReader, String, MergeOption)

在特定的實體集並使用指定的合併選項,將包含實體資料之資料列的 DbDataReader 轉譯為所要求之實體型別的物件。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.

Translate<TElement>(DbDataReader)

將包含實體資料之資料列的 DbDataReader,轉譯成所要求的實體型別。Translates a DbDataReader that contains rows of entity data to objects of the requested entity type.

public:
generic <typename TElement>
 System::Data::Objects::ObjectResult<TElement> ^ Translate(System::Data::Common::DbDataReader ^ reader);
public System.Data.Objects.ObjectResult<TElement> Translate<TElement> (System.Data.Common.DbDataReader reader);
member this.Translate : System.Data.Common.DbDataReader -> System.Data.Objects.ObjectResult<'Element>
Public Function Translate(Of TElement) (reader As DbDataReader) As ObjectResult(Of TElement)

類型參數

TElement

DbDataReader 中之資料的實體型別。The entity type of the data in the DbDataReader.

參數

reader
DbDataReader

DbDataReader,包含要轉譯為實體物件的實體資料。The DbDataReader that contains entity data to translate into entity objects.

傳回

ObjectResult<TElement>

型別為 TResult 之物件的列舉。An enumeration of objects of type TResult.

例外狀況

readernull 時。When reader is null.

備註

Translate方法是用來將中的實體資料轉譯 DbDataReader 成所要求之類型的物件。The Translate method is used to translate entity data from a DbDataReader into objects of the requested type. 當執行以傳回實體資料時,會自動執行此程式 ObjectQuery<T>This process is performed automatically when an ObjectQuery<T> is executed to return entity data. Translate方法可讓您針對資料來源執行標準 ADO.NET 查詢,並將傳回的資料列轉譯為實體物件。The Translate method enables you to execute a standard ADO.NET query against a data source and translate the returned data rows into entity objects.

提供的 DbDataReader 必須包含對應至要求之實體類型的資料。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

適用於

Translate<TEntity>(DbDataReader, String, MergeOption)

在特定的實體集並使用指定的合併選項,將包含實體資料之資料列的 DbDataReader 轉譯為所要求之實體型別的物件。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.

public:
generic <typename TEntity>
 System::Data::Objects::ObjectResult<TEntity> ^ Translate(System::Data::Common::DbDataReader ^ reader, System::String ^ entitySetName, System::Data::Objects::MergeOption mergeOption);
public System.Data.Objects.ObjectResult<TEntity> Translate<TEntity> (System.Data.Common.DbDataReader reader, string entitySetName, System.Data.Objects.MergeOption mergeOption);
member this.Translate : System.Data.Common.DbDataReader * string * System.Data.Objects.MergeOption -> System.Data.Objects.ObjectResult<'Entity>
Public Function Translate(Of TEntity) (reader As DbDataReader, entitySetName As String, mergeOption As MergeOption) As ObjectResult(Of TEntity)

類型參數

TEntity

DbDataReader 中之資料的實體型別。The entity type of the data in the DbDataReader.

參數

reader
DbDataReader

DbDataReader,包含要轉譯為實體物件的實體資料。The DbDataReader that contains entity data to translate into entity objects.

entitySetName
String

TEntity 型別的實體集。The entity set of the TEntity type.

mergeOption
MergeOption

在轉譯的物件加入至物件內容時所要使用的 MergeOptionThe MergeOption to use when translated objects are added to the object context. 預設為 AppendOnlyThe default is AppendOnly.

傳回

ObjectResult<TEntity>

型別為 TResult 之物件的列舉。An enumeration of objects of type TResult.

例外狀況

readernull 時。When reader is null.

當提供的 mergeOption 不是有效的 MergeOption 值時。When the supplied mergeOption is not a valid MergeOption value.

當提供的 entitySetName 不是 TResult 型別的有效實體集時。When the supplied entitySetName is not a valid entity set for the TResult type.

備註

Translate方法是用來將中的實體資料轉譯 DbDataReader 成所要求之類型的物件。The Translate method is used to translate entity data from a DbDataReader into objects of the requested type. 當執行以傳回實體資料時,會自動執行此程式 ObjectQuery<T>This process is performed automatically when an ObjectQuery<T> is executed to return entity data. Translate方法可讓您針對資料來源執行標準 ADO.NET 查詢,並將傳回的資料列轉譯為實體物件。The Translate method enables you to execute a standard ADO.NET query against a data source and translate the returned data rows into entity objects.

提供的 DbDataReader 必須包含對應至要求之實體類型的資料。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

適用於