簡體   English   中英

從 EDM model 中查找 Principal 端和 Dependent 端

[英]Find Principal end and Dependent end out of EDM model

我需要使用 EDM model 找到所有外鍵。 我能夠使用 Systm.Data.Entity.Core.Metadata 類和方法提取許多有用的信息,但仍然無法從關聯或關系中獲取 Principal 和 Dependent。
ReferentialConstraint class 具有公共屬性FromRole / ToRole ,其中一個是 Principal ,另一個是 Dependent 但我不確定哪些是確切的。
ReferentialConstraint有私有字段PrincipalEndDependentEnd可能會幫助我,但我不想通過反射訪問它們。 有沒有更好的方法來確定什么是 Principal 以及什么是 Dependent?

PS:我在這個EF6 中看到了解決方案 - 如何從 NavigationProperty 問題中確定主體/依賴方,但沒有證據證明它是 100% 正確的。

好的,我終於在這里找到了源代碼

internal AssociationEndMember PrincipalEnd
{
    get { return (AssociationEndMember)FromRole; }
}

internal AssociationEndMember DependentEnd
{
    get { return (AssociationEndMember)ToRole; }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM