RelatedEnd.ValidateLoad<TEntity>(MergeOption, String) 方法

定義

確保一個或多個相關物件可以成功載入本機集合或參考中。Ensures that the related object or objects can be successfully loaded into the local collection or reference.

protected:
generic <typename TEntity>
 System::Data::Objects::ObjectQuery<TEntity> ^ ValidateLoad(System::Data::Objects::MergeOption mergeOption, System::String ^ relatedEndName);
protected System.Data.Objects.ObjectQuery<TEntity> ValidateLoad<TEntity> (System.Data.Objects.MergeOption mergeOption, string relatedEndName);
member this.ValidateLoad : System.Data.Objects.MergeOption * string -> System.Data.Objects.ObjectQuery<'Entity>
Protected Function ValidateLoad(Of TEntity) (mergeOption As MergeOption, relatedEndName As String) As ObjectQuery(Of TEntity)

類型參數

TEntity

要驗證之物件的型別。The type of the object to validate.

參數

mergeOption
MergeOption

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

relatedEndName
String

相關端的名稱。The name of the related end.

傳回

ObjectQuery<TEntity>

用來在相關端載入一個或多個物件的 ObjectQuery<T>An ObjectQuery<T> that is used to load the object or objects at the related end.

例外狀況

當來源物件是使用 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 狀態中,或者用於 MergeOptionLoadNoTracking 時。When the source object is being tracked but is in the Added or Deleted state or the MergeOption used for Load is NoTracking.

備註

物件服務藉 ObjectQuery<T> 由呼叫 IRelatedEnd. CreateSourceQuery 方法來取得。Object Services obtains the ObjectQuery<T> by calling the IRelatedEnd.CreateSourceQuery method.

物件服務會先呼叫 ValidateLoad<TEntity> 方法,然後再執行載入作業,以便確保作業會成功。Object Services calls the ValidateLoad<TEntity> method before executing a load operation to ensure that the operation will succeed.

適用於