IRelatedEnd Interface
Definição
Define o final de uma relação.Defines the end of a relationship.
public interface class IRelatedEnd
public interface IRelatedEnd
type IRelatedEnd = interface
Public Interface IRelatedEnd
- Derivado
Exemplos
O exemplo neste tópico baseia-se no Microsoft SQL Server exemplos de produto: banco de dados, que foi gerado pelo Assistente de modelo de dados de entidade.The example in this topic is based on the Microsoft SQL Server Product Samples: Database, which was generated by the Entity Data Model Wizard.
O exemplo a seguir adiciona novas SalesOrderHeader entidades à Contact entidade.The following example adds new SalesOrderHeader entities to the Contact entity. Em seguida, ele obtém todas as extremidades relacionadas da Contact entidade e exibe o nome da relação, o nome da função de origem e o nome da função de destino para cada extremidade relacionada.Then it gets all related ends from the Contact entity and displays relationship name, source role name, and target role name for each related end.
using (AdventureWorksEntities context =
new AdventureWorksEntities())
{
Contact contact = new Contact();
// Create a new SalesOrderHeader.
SalesOrderHeader newSalesOrder1 = new SalesOrderHeader();
// Add SalesOrderHeader to the Contact.
contact.SalesOrderHeaders.Add(newSalesOrder1);
// Create another SalesOrderHeader.
SalesOrderHeader newSalesOrder2 = new SalesOrderHeader();
// Add SalesOrderHeader to the Contact.
contact.SalesOrderHeaders.Add(newSalesOrder2);
// Get all related ends
IEnumerable<IRelatedEnd> relEnds =
((IEntityWithRelationships)contact).RelationshipManager
.GetAllRelatedEnds();
foreach (IRelatedEnd relEnd in relEnds)
{
Console.WriteLine("Relationship Name: {0}", relEnd.RelationshipName);
Console.WriteLine("Source Role Name: {0}", relEnd.SourceRoleName);
Console.WriteLine("Target Role Name: {0}", relEnd.TargetRoleName);
}
}
Using context As New AdventureWorksEntities()
Dim contact As New Contact()
' Create a new SalesOrderHeader.
Dim newSalesOrder1 As New SalesOrderHeader()
' Add SalesOrderHeader to the Contact.
contact.SalesOrderHeaders.Add(newSalesOrder1)
' Create another SalesOrderHeader.
Dim newSalesOrder2 As New SalesOrderHeader()
' Add SalesOrderHeader to the Contact.
contact.SalesOrderHeaders.Add(newSalesOrder2)
' Get all related ends
Dim relEnds As IEnumerable(Of IRelatedEnd) = DirectCast(contact, IEntityWithRelationships).RelationshipManager.GetAllRelatedEnds()
For Each relEnd As IRelatedEnd In relEnds
Console.WriteLine("Relationship Name: {0}", relEnd.RelationshipName)
Console.WriteLine("Source Role Name: {0}", relEnd.SourceRoleName)
Console.WriteLine("Target Role Name: {0}", relEnd.TargetRoleName)
Next
End Using
Comentários
IRelatedEnd define os requisitos para um objeto que representa um fim em uma associação.IRelatedEnd defines the requirements for an object that represents an end in an association. Essa interface é implementada pela RelatedEnd classe.This interface is implemented by the RelatedEnd class. RelatedEnd é a classe base para as EntityCollection<TEntity> EntityReference<TEntity> classes e.RelatedEnd is the base class for the EntityCollection<TEntity> and EntityReference<TEntity> classes.
Propriedades
| IsLoaded |
Obtém um valor que indica se todos os objetos relacionados foram carregados.Gets a value that indicates whether all related objects have been loaded. |
| RelationshipName |
Obtém o nome da relação na qual essa extremidade relacionada participa.Gets the name of the relationship in which this related end participates. |
| RelationshipSet |
Retorna uma referência aos metadados da extremidade relacionada.Returns a reference to the metadata for the related end. |
| SourceRoleName |
Obtém o nome da função na extremidade de origem da relação.Gets the role name at the source end of the relationship. |
| TargetRoleName |
Obtém o nome da função na extremidade de destino da relação.Gets the role name at the target end of the relationship. |
Métodos
| Add(IEntityWithRelationships) |
Adiciona um objeto à extremidade relacionada.Adds an object to the related end. |
| Add(Object) |
Adiciona um objeto à extremidade relacionada.Adds an object to the related end. |
| Attach(IEntityWithRelationships) |
Define uma relação entre dois objetos anexados.Defines a relationship between two attached objects. |
| Attach(Object) |
Define uma relação entre dois objetos anexados.Defines a relationship between two attached objects. |
| CreateSourceQuery() |
Retorna um IEnumerable que representa os objetos que pertencem à extremidade relacionada.Returns an IEnumerable that represents the objects that belong to the related end. |
| GetEnumerator() |
Retorna um IEnumerator que itera na coleção de objetos relacionados.Returns an IEnumerator that iterates through the collection of related objects. |
| Load() |
Carrega um ou mais objetos relacionados nessa extremidade relacionada, com a opção de mesclagem padrão.Loads the related object or objects into this related end with the default merge option. |
| Load(MergeOption) |
Carrega um ou mais objetos relacionados na extremidade relacionada, com a opção de mesclagem especificada.Loads the related object or objects into the related end with the specified merge option. |
| Remove(IEntityWithRelationships) |
Remove um objeto da coleção de objetos na extremidade relacionada.Removes an object from the collection of objects at the related end. |
| Remove(Object) |
Remove um objeto da coleção de objetos na extremidade relacionada.Removes an object from the collection of objects at the related end. |