ObjectStateManager.ChangeRelationshipState Method

Definition

Overloads

ChangeRelationshipState(Object, Object, String, EntityState)

Changes the state of the relationship between two entity objects that is specified based on the two related objects and the name of the navigation property.

ChangeRelationshipState(Object, Object, String, String, EntityState)

Changes the state of the relationship between two entity objects that is specified based on the two related objects and the properties of the relationship.

ChangeRelationshipState<TEntity>(TEntity, Object, Expression<Func<TEntity,Object>>, EntityState)

Changes the state of the relationship between two entity objects that is specified based on the two related objects and a LINQ expression that defines the navigation property.

ChangeRelationshipState(Object, Object, String, EntityState)

Changes the state of the relationship between two entity objects that is specified based on the two related objects and the name of the navigation property.

public virtual System.Data.Entity.Core.Objects.ObjectStateEntry ChangeRelationshipState (object sourceEntity, object targetEntity, string navigationProperty, System.Data.Entity.EntityState relationshipState);
abstract member ChangeRelationshipState : obj * obj * string * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry
override this.ChangeRelationshipState : obj * obj * string * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry
Public Overridable Function ChangeRelationshipState (sourceEntity As Object, targetEntity As Object, navigationProperty As String, relationshipState As EntityState) As ObjectStateEntry

Parameters

sourceEntity
Object

The object instance or EntityKey of the source entity at one end of the relationship.

targetEntity
Object

The object instance or EntityKey of the target entity at the other end of the relationship.

navigationProperty
String

The name of the navigation property on source that returns the specified target .

relationshipState
EntityState

The requested EntityState of the specified relationship.

Returns

The ObjectStateEntry for the relationship that was changed.

Exceptions

When source or target is null.

When trying to change the state of the relationship to a state other than Deleted or Detached when either source or target is in a Deleted state or when you try to change the state of the relationship to a state other than Added or Detached when either source or target is in an state or when state is not a valid EntityState value

Applies to

ChangeRelationshipState(Object, Object, String, String, EntityState)

Changes the state of the relationship between two entity objects that is specified based on the two related objects and the properties of the relationship.

public virtual System.Data.Entity.Core.Objects.ObjectStateEntry ChangeRelationshipState (object sourceEntity, object targetEntity, string relationshipName, string targetRoleName, System.Data.Entity.EntityState relationshipState);
abstract member ChangeRelationshipState : obj * obj * string * string * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry
override this.ChangeRelationshipState : obj * obj * string * string * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry
Public Overridable Function ChangeRelationshipState (sourceEntity As Object, targetEntity As Object, relationshipName As String, targetRoleName As String, relationshipState As EntityState) As ObjectStateEntry

Parameters

sourceEntity
Object

The object instance or EntityKey of the source entity at one end of the relationship.

targetEntity
Object

The object instance or EntityKey of the target entity at the other end of the relationship.

relationshipName
String

The name of the relationship.

targetRoleName
String

The role name at the target end of the relationship.

relationshipState
EntityState

The requested EntityState of the specified relationship.

Returns

The ObjectStateEntry for the relationship that was changed.

Exceptions

When source or target is null.

When you try to change the state of the relationship to a state other than Deleted or Detached when either source or target is in a Deleted state or when you try to change the state of the relationship to a state other than Added or Detached when either source or target is in an Added state or when state is not a valid EntityState value.

Applies to

ChangeRelationshipState<TEntity>(TEntity, Object, Expression<Func<TEntity,Object>>, EntityState)

Changes the state of the relationship between two entity objects that is specified based on the two related objects and a LINQ expression that defines the navigation property.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public virtual System.Data.Entity.Core.Objects.ObjectStateEntry ChangeRelationshipState<TEntity> (TEntity sourceEntity, object targetEntity, System.Linq.Expressions.Expression<Func<TEntity,object>> navigationPropertySelector, System.Data.Entity.EntityState relationshipState) where TEntity : class;
abstract member ChangeRelationshipState : 'Entity * obj * System.Linq.Expressions.Expression<Func<'Entity, obj>> * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry (requires 'Entity : null)
override this.ChangeRelationshipState : 'Entity * obj * System.Linq.Expressions.Expression<Func<'Entity, obj>> * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry (requires 'Entity : null)
Public Overridable Function ChangeRelationshipState(Of TEntity As Class) (sourceEntity As TEntity, targetEntity As Object, navigationPropertySelector As Expression(Of Func(Of TEntity, Object)), relationshipState As EntityState) As ObjectStateEntry

Type Parameters

TEntity

The entity type of the source object.

Parameters

sourceEntity
TEntity

The object instance or EntityKey of the source entity at one end of the relationship.

targetEntity
Object

The object instance or EntityKey of the target entity at the other end of the relationship.

navigationPropertySelector
Expression<Func<TEntity,Object>>

A LINQ expression that selects the navigation property on source that returns the specified target .

relationshipState
EntityState

The requested EntityState of the specified relationship.

Returns

The ObjectStateEntry for the relationship that was changed.

Attributes

Exceptions

When source , target , or selector is null.

selector is malformed or cannot return a navigation property.

When you try to change the state of the relationship to a state other than Deleted or Detached when either source or target is in a Deleted state or when you try to change the state of the relationship to a state other than Added or Detached when either source or target is in an Added state or when state is not a valid EntityState value.

Applies to