开发者

Perform a Linq Many to Many Query

In SQL I have 2 tables.


Sport            Athlete

SportId          AthleteId

SportName    AthleteName

开发者_如何学C


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.


In your Sport entity, there will be a so called "navigation property" Athletes that contains all Athletes that belong to that Sport instance.
The same is true the other way around.


Can't you do A.Sports and get that list?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜