IRelatedEnd.RelationshipName 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取此相关端所参与的关系的名称。
public:
property System::String ^ RelationshipName { System::String ^ get(); };
public string RelationshipName { get; }
member this.RelationshipName : string
Public ReadOnly Property RelationshipName As String
属性值
此 IRelatedEnd 所参与的关系的名称。 关系名称不由命名空间限定。
示例
以下示例向 实体添加新 SalesOrderHeader
实体 Contact
。 然后,它从 Contact
实体获取所有相关端,并显示每个相关端的关系名称、源角色名称和目标角色名称。
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);
}
}