子实体和导航属性 [英] Child Entities and Navigation Properties
本文介绍了子实体和导航属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对EF很新,所以请原谅我...我有一个有4个实体的模型都通过外键相互关联。
用户---> SkillsSets ---> SkillMatches --->程序
我想为特定用户检索程序列表,我的问题是我的查询应该如何:
应该使用JOIN?我希望我可以沿着用户的不同导航属性一直"跳"到程序。
任何帮助都会被大家推荐。
John
解决方案
嗨约翰,
如果我正确理解你的问题你应该能够这样做:
var programmesByUsers = from p in < font style ="font-size:11px"> MyEntity.Programmes 其中p .SkillMatches.SkillSets.Users.UserID =用户ID 选择p;
Hi,
I'm pretty new to EF so please forgive me... I have a model with 4 Entities in it all related to each other via foreign keys.
Users ---> SkillsSets ---> SkillMatches ---> Programmes
I'd like to retrieve a list of Programmes for a particular user, my question is how should my query look like :
Should be using JOIN's ? I was hoping i could 'hop' along the different Navigation Properties from Users all the way to Programmes.
Any help would be much appriecated.
John解决方案Hi John,
If I am understanding your question correctly you should be able to do this:
var programmesByUsers = from p in MyEntity.Programmes where p.SkillMatches.SkillSets.Users.UserID = userID select p;
这篇关于子实体和导航属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文