共用方式為


ObjectContext.LoadProperty<TEntity> 方法 (TEntity, Expression<Func<TEntity, Object>>, MergeOption)

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

由指定的 LINQ 查詢和使用指定的合併選項,明確地載入所提供之物件的相關物件。

命名空間:  System.Data.Entity.Core.Objects
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
Public Overridable Sub LoadProperty(Of TEntity) ( _
    entity As TEntity, _
    selector As Expression(Of Func(Of TEntity, Object)), _
    mergeOption As MergeOption _
)
'用途
Dim instance As ObjectContext 
Dim entity As TEntity
Dim selector As Expression(Of Func(Of TEntity, Object))
Dim mergeOption As MergeOption

instance.LoadProperty(entity, selector, _
    mergeOption)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public virtual void LoadProperty<TEntity>(
    TEntity entity,
    Expression<Func<TEntity, Object>> selector,
    MergeOption mergeOption
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
public:
generic<typename TEntity>
virtual void LoadProperty(
    TEntity entity, 
    Expression<Func<TEntity, Object^>^>^ selector, 
    MergeOption mergeOption
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
abstract LoadProperty : 
        entity:'TEntity * 
        selector:Expression<Func<'TEntity, Object>> * 
        mergeOption:MergeOption -> unit 
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
override LoadProperty : 
        entity:'TEntity * 
        selector:Expression<Func<'TEntity, Object>> * 
        mergeOption:MergeOption -> unit
JScript does not support generic types and methods.

類型參數

  • TEntity
    實體的類型。

參數

  • entity
    類型:TEntity
    要載入相關物件的來源物件。

例外狀況

例外狀況 條件
ArgumentException

selector 並未提供有效的輸入參數。

ArgumentNullException

selector 為 null。

InvalidOperationException

實體的狀態為 Detached、[F:System.Data.Entity.EntityState.Added,] 或 Deleted,或者實體已附加至 ObjectContext 的其他執行個體。

請參閱

參考

ObjectContext 類別

LoadProperty 多載

System.Data.Entity.Core.Objects 命名空間