简体   繁体   English

使用SQL和Linq(实体框架/实体)的多对多关系

[英]Many to Many relationship using SQL and Linq (entity framework/to entities)

I have two tables: 我有两张桌子:

- Attendees
- Events

Normally, I would create a mapping table ' EventAttendeeMap ' to link these tables into a many to many relationship. 通常,我会创建一个映射表' EventAttendeeMap '来将这些表链接成多对多的关系。

Is this the best way of doing so? 这是最好的方式吗? Should I store the list of AttendeeId s in an xml column instead on the Events table? 我应该将AttendeeId列表存储在xml列而不是Events表中吗?

I am using .NET 3.5/4 with Linq as the DAL (although I think this is irrelevant to the design question being asked, possibly). 我使用.NET 3.5 / 4和Linq作为DAL(虽然我认为这与被问到的设计问题无关)。

Interested to see what people's opinions are. 有兴趣了解人们的意见。

Thanks. 谢谢。 Dave 戴夫

映射表绝对是最好的方法 - 实体框架将映射表转换为两侧的实体集合,表本身将基本消失。

In short yes - create a mapping table to hold the event id and the attendee id. 简而言之是 - 创建一个映射表来保存事件ID和与会者ID。

There is a good question here that might be of interest to you. 有一个很好的问题, 在这里 ,可能是你的兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM