ObjectContext.Translate<TEntity> 方法 (DbDataReader, String, MergeOption)
[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]
在特定的實體集並使用指定的合併選項,將包含實體資料之資料列的 DbDataReader 轉譯為所要求之實體類型的物件。
命名空間: System.Data.Entity.Core.Objects
組件: EntityFramework (在 EntityFramework.dll 中)
語法
'宣告
<SuppressMessageAttribute("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification := "Generic parameters are required for strong-typing of the return type.")> _
Public Overridable Function Translate(Of TEntity) ( _
reader As DbDataReader, _
entitySetName As String, _
mergeOption As MergeOption _
) As ObjectResult(Of TEntity)
'用途
Dim instance As ObjectContext
Dim reader As DbDataReader
Dim entitySetName As String
Dim mergeOption As MergeOption
Dim returnValue As ObjectResult(Of TEntity)
returnValue = instance.Translate(reader, _
entitySetName, mergeOption)
[SuppressMessageAttribute("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Generic parameters are required for strong-typing of the return type.")]
public virtual ObjectResult<TEntity> Translate<TEntity>(
DbDataReader reader,
string entitySetName,
MergeOption mergeOption
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1004:GenericMethodsShouldProvideTypeParameter", Justification = L"Generic parameters are required for strong-typing of the return type.")]
public:
generic<typename TEntity>
virtual ObjectResult<TEntity>^ Translate(
DbDataReader^ reader,
String^ entitySetName,
MergeOption mergeOption
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Generic parameters are required for strong-typing of the return type.")>]
abstract Translate :
reader:DbDataReader *
entitySetName:string *
mergeOption:MergeOption -> ObjectResult<'TEntity>
[<SuppressMessageAttribute("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Generic parameters are required for strong-typing of the return type.")>]
override Translate :
reader:DbDataReader *
entitySetName:string *
mergeOption:MergeOption -> ObjectResult<'TEntity>
JScript does not support generic types and methods.
類型參數
- TEntity
實體類型。
參數
- reader
類型:System.Data.Common.DbDataReader
DbDataReader,包含要轉譯為實體物件的實體資料。
- entitySetName
類型:System.String
TResult 類型的實體集。
- mergeOption
類型:System.Data.Entity.Core.Objects.MergeOption
在轉譯的物件加入至物件內容時所要使用的 MergeOption。 預設為 AppendOnly。
傳回值
類型:System.Data.Entity.Core.Objects.ObjectResult<TEntity>
TResult 類型的物件列舉。
例外狀況
例外狀況 | 條件 |
---|---|
ArgumentNullException | 當 reader 為 null 時。 |
ArgumentOutOfRangeException | 當提供的 mergeOption 不是有效的 MergeOption 值時。 |
InvalidOperationException | 當提供的 entitySetName 不是 TResult 類型的有效實體集時。 |