簡體   English   中英

實體框架:與其他表進行比較后,帶來一個表列表

[英]Entity framework : Bring a list of tables after comparing with other table

美好的一天,

我有一個有5張桌子的圖表。 我的圖

如您所見,我有一個類別表和詳細的醫學研究。 還有兩個相似的表:OtherStudy和OtherMedicalStudyDetails。 這些表還具有一些其他圖表中未包含的前導鍵。 為了簡單起見,我提供了一個看起來不太好的數據庫圖,但是它使解釋我的問題更簡單(有人可以告訴我,我應該只使用medicalStudy和medicalStudy詳細信息表,而不要使用其他兩個,但是我想保持這樣的圖表)。

我想做的是,在添加(使用C#實體框架)帶有其MedicalStudyDetails的medicalStudy之后,比較兩個明細表,並列出所有“ OtherStudy”的列表,其中(MedicalStudyDetails.FK_otherTable==OtherMedicalStudyDetails.FK_otherTable&& MedicalStudyDetails.FK_anotherTable==OtherMedicalStudyDetails.FK_anotherTable) 請注意,應該為添加的每個MedicalStudyDetails完成此比較。

有沒有辦法使用這樣的sintax將提到的列表帶入?

 var otherStudy= _dbContext.MedicalStudyDetails.Include(...)
            .Where(...)
            .ToList();

您是否不需要多個子句內部聯接才能實現此目標?

from msd in _dbContext.MedicalStudyDetails
join omsd in _dbContext.OtherMedicalStudyDetails on 
    new {msd.FK_otherTable, msd.FK_anotherTable} equals new { omsd.FK_otherTable, omsd.FK_anotherTable}
where ...
select ...

暫無
暫無

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

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