RelatedEnd.Load 方法

定義

在衍生類別中覆寫時,將一個或多個相關物件載入本機集合或參考中。When overridden in a derived class, loads the related object or objects into the local collection or reference.

多載

Load()

在衍生類別中覆寫時,使用預設合併選項,將一個或多個相關物件載入相關端中。When overridden in a derived class, loads the related object or objects into the related end with the default merge option.

Load(MergeOption)

在衍生類別 (Derived Class) 中覆寫時,使用指定的合併選項,從相關端中載入一個或多個物件。When overridden in a derived class, loads an object or objects from the related end with the specified merge option.

Load()

在衍生類別中覆寫時,使用預設合併選項,將一個或多個相關物件載入相關端中。When overridden in a derived class, loads the related object or objects into the related end with the default merge option.

public:
 virtual void Load();
public void Load ();
abstract member Load : unit -> unit
override this.Load : unit -> unit
Public Sub Load ()

實作

例外狀況

當來源物件是使用 NoTracking 查詢所擷取的,而且 MergeOption 不是 NoTracking 或者相關物件已經載入時。When the source object was retrieved by using a NoTracking query and the MergeOption is not NoTracking or the related objects are already loaded.

-或--or-

當來源物件沒有附加至 ObjectContext 時。When the source object is not attached to the ObjectContext.

-或--or-

當來源物件正在追蹤中,但是處於 AddedDeleted 狀態中,或者用於 MergeOptionLoad()NoTracking 時。When the source object is being tracked but is in the Added or Deleted state or the MergeOption used for Load() is NoTracking.

備註

預設合併選項為 AppendOnly (適用於追蹤的物件) 或 NoTracking (當物件並未在 ObjectStateManager 中追蹤時)。The default merge option is AppendOnly for tracked objects or NoTracking when the object is not tracked in the ObjectStateManager. 若要指定以外的合併選項 AppendOnly ,請 LoadEntityCollection<TEntity>EntityReference<TEntity> 接受特定參數的上呼叫方法 MergeOptionTo specify a merge option other than AppendOnly, call the Load method on the EntityCollection<TEntity> or the EntityReference<TEntity> that takes a specific MergeOption parameter.

呼叫 Load 方法會將旗標設定 IsLoadedtrueCalling the Load method sets the IsLoaded flag to true.

Load無論是否為,方法都會從資料來源載入相關物件 IsLoaded trueThe Load method loads related objects from the data source whether or not IsLoaded is true.

適用於

Load(MergeOption)

在衍生類別 (Derived Class) 中覆寫時,使用指定的合併選項,從相關端中載入一個或多個物件。When overridden in a derived class, loads an object or objects from the related end with the specified merge option.

public:
 abstract void Load(System::Data::Objects::MergeOption mergeOption);
public abstract void Load (System.Data.Objects.MergeOption mergeOption);
abstract member Load : System.Data.Objects.MergeOption -> unit
Public MustOverride Sub Load (mergeOption As MergeOption)

參數

mergeOption
MergeOption

將物件合併至現有的 MergeOption 時要使用的 EntityCollection<TEntity>The MergeOption to use when merging objects into an existing EntityCollection<TEntity>.

實作

例外狀況

當來源物件是使用 NoTracking 查詢所擷取的,而且 MergeOption 不是 NoTracking 或者相關物件已經載入時。When the source object was retrieved by using a NoTracking query and the MergeOption is not NoTracking or the related objects are already loaded.

-或--or-

當來源物件沒有附加至 ObjectContext 時。When the source object is not attached to the ObjectContext.

-或--or-

當來源物件正在追蹤中,但是處於 AddedDeleted 狀態中,或者用於 MergeOptionLoad()NoTracking 時。When the source object is being tracked but is in the Added or Deleted state or the MergeOption used for Load() is NoTracking.

備註

EntityCollection<TEntity>EntityReference<TEntity> 都會覆寫這個方法來載入相關物件。Both EntityCollection<TEntity> and EntityReference<TEntity> override this method to load related objects. Load 呼叫以從導覽屬性所公開的相關端明確載入相關物件。Load is called to explicitly load related objects from a related end exposed by a navigation property. 如需詳細資訊,請參閱 載入相關物件For more information, see Loading Related Objects.

呼叫 Load 方法會將旗標設定 IsLoadedtrueCalling the Load method sets the IsLoaded flag to true.

Load無論是否為,方法都會從資料來源載入相關物件 IsLoaded trueThe Load method loads related objects from the data source whether or not IsLoaded is true.

預設合併選項為 AppendOnly (適用於追蹤的物件) 或 NoTracking (當物件並未在 ObjectStateManager 中追蹤時)。The default merge option is AppendOnly for tracked objects or NoTracking when the object is not tracked in the ObjectStateManager.

適用於