RelatedEnd.ValidateLoad<TEntity>(MergeOption, String) Method

Definition

Ensures that the related object or objects can be successfully loaded into the local collection or reference.

C#
protected System.Data.Objects.ObjectQuery<TEntity> ValidateLoad<TEntity>(System.Data.Objects.MergeOption mergeOption, string relatedEndName);

Type Parameters

TEntity

The type of the object to validate.

Parameters

mergeOption
MergeOption

The MergeOption to use when merging objects into an existing EntityCollection<TEntity>.

relatedEndName
String

The name of the related end.

Returns

ObjectQuery<TEntity>

An ObjectQuery<T> that is used to load the object or objects at the related end.

Exceptions

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-

When the source object is not attached to the ObjectContext.

-or-

When the source object is being tracked but is in the Added or Deleted state or the MergeOption used for Load is NoTracking.

Remarks

Object Services obtains the ObjectQuery<T> by calling the IRelatedEnd.CreateSourceQuery method.

Object Services calls the ValidateLoad<TEntity> method before executing a load operation to ensure that the operation will succeed.

Applies to

Product Versions
.NET Framework 3.5