//--------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner mirszy // @backupOwner sparra //--------------------------------------------------------------------- using System.Data; using System.Data.Common; using System.Data.Common.CommandTrees; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Data.Metadata.Edm; namespace System.Data.Objects.DataClasses { /// /// Represents one end of a relationship. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] public interface IRelatedEnd { // ---------- // Properties // ---------- /// /// IsLoaded returns true if and only if Load was called. /// bool IsLoaded { get;} /// /// Name of the relationship in which this IRelatedEnd is participating /// string RelationshipName { get; } /// /// Name of the relationship source role used to generate this IRelatedEnd /// string SourceRoleName { get; } /// /// Name of the relationship target role used to generate this IRelatedEnd /// string TargetRoleName { get; } /// /// The relationship metadata cooresponding to this IRelatedEnd /// RelationshipSet RelationshipSet { get; } // ------- // Methods // ------- /// /// Loads the related entity or entities into the related end using the default merge option /// void Load(); /// /// Loads the related entity or entities into the related end using the specified merge option /// void Load(MergeOption mergeOption); /// /// Adds an entity to the related end. If the owner is /// attached to a cache then the all the connected ends are /// added to the object cache and their corresponding relationships /// are also added to the ObjectStateManager. The RelatedEnd of the /// relationship is also fixed. /// /// /// Entity instance to add to the related end /// void Add(IEntityWithRelationships entity); /// /// Adds an entity to the related end. If the owner is /// attached to a cache then the all the connected ends are /// added to the object cache and their corresponding relationships /// are also added to the ObjectStateManager. The RelatedEnd of the /// relationship is also fixed. /// /// This overload is meant to be used by classes that do not implement IEntityWithRelationships. /// /// /// Entity instance to add to the related end /// void Add(object entity); /// /// Removes an entity from the related end. If owner is /// attached to a cache, marks relationship for deletion and if /// the relationship is composition also marks the entity for deletion. /// /// /// Entity instance to remove from the related end /// /// Returns true if the entity was successfully removed, false if the entity was not part of the IRelatedEnd. bool Remove(IEntityWithRelationships entity); /// /// Removes an entity from the related end. If owner is /// attached to a cache, marks relationship for deletion and if /// the relationship is composition also marks the entity for deletion. /// /// This overload is meant to be used by classes that do not implement IEntityWithRelationships. /// /// /// Entity instance to remove from the related end /// /// Returns true if the entity was successfully removed, false if the entity was not part of the IRelatedEnd. bool Remove(object entity); /// /// Attaches an entity to the related end. If the related end is already filled /// or partially filled, this merges the existing entities with the given entity. The given /// entity is not assumed to be the complete set of related entities. /// /// Owner and all entities passed in must be in Unchanged or Modified state. /// Deleted elements are allowed only when the state manager is already tracking the relationship /// instance. /// /// The entity to attach to the related end /// Thrown when is null. /// Thrown when the entity cannot be related via the current relationship end. void Attach(IEntityWithRelationships entity); /// /// Attaches an entity to the related end. If the related end is already filled /// or partially filled, this merges the existing entities with the given entity. The given /// entity is not assumed to be the complete set of related entities. /// /// Owner and all entities passed in must be in Unchanged or Modified state. /// Deleted elements are allowed only when the state manager is already tracking the relationship /// instance. /// /// This overload is meant to be used by classes that do not implement IEntityWithRelationships. /// /// The entity to attach to the related end /// Thrown when is null. /// Thrown when the entity cannot be related via the current relationship end. void Attach(object entity); /// /// This is the query which represents the source of the /// related end. It is constructed on demand using the /// _connection and _cache fields and a query string based on /// the type of relationship end and the metadata passed into its /// constructor. /// IEnumerable CreateSourceQuery(); /// /// Returns an enumerator of all of the values contained within this related end /// IEnumerator GetEnumerator(); } }