使用SQL和Linq(实体框架/到实体)的多对多关系 [英] Many to Many relationship using SQL and Linq (entity framework/to entities)

查看:105
本文介绍了使用SQL和Linq(实体框架/到实体)的多对多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表:

- Attendees
- Events

通常,我会创建一个映射表'EventAttendeeMap'来将这些表链接为多对多关系.

Normally, I would create a mapping table 'EventAttendeeMap' to link these tables into a many to many relationship.

这是最好的方法吗? 我应该将AttendeeId的列表存储在xml列中,而不是存储在事件"表中吗?

Is this the best way of doing so? Should I store the list of AttendeeIds in an xml column instead on the Events table?

我正在将.net 3.5/4与Linq用作DAL(尽管我认为这可能与所提出的设计问题无关).

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).

有兴趣了解人们的看法.

Interested to see what people's opinions are.

谢谢. 戴夫

推荐答案

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

A mapping table is definitely the best way to do it - the Entity Framework will convert the mapping table into a collection of entities on both sides and the table itself will essentially disappear.

这篇关于使用SQL和Linq(实体框架/到实体)的多对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆