执行 Linq 多对多查询
在 SQL 中我有 2 个表。
Sport Athlete
SportId AthleteId
SportName AthleteName
Their relation is many to many. So there is a third table that join them.
AthleteSport
AthleteId
SprortId
如果我使用向导创建实体数据模型,第三个表将消失,并且仅创建具有多对多关系的 2 个主表。
我如何执行查询来找出运动员“A”的运动类型?如何改变它们或添加新的运动?
我想使用 linq 和 c#。 谢谢。
In SQL I have 2 tables.
Sport Athlete
SportId AthleteId
SportName AthleteName
Their relation is many to many. So there is a third table that join them.
AthleteSport
AthleteId
SprortId
If i create an entity data model using the wizard the third table is disapeared and only creates the 2 main tables with the many to many relation.
how can I perform a query to find out what kind of sports athlete 'A' does? How to change them or add a new sport?
I want to use linq and c#.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的
Sport
实体中,将有一个所谓的“导航属性”Athletes
,其中包含属于该Sport
实例的所有运动员。反之亦然。
In your
Sport
entity, there will be a so called "navigation property"Athletes
that contains all Athletes that belong to thatSport
instance.The same is true the other way around.
您不能参加
A.Sports
并获取该列表吗?Can't you do
A.Sports
and get that list?