如何在LINQ中建立多对多关系?

时间:2022-02-16 20:14:51

I have two tables say, t1 and t2 that have t1.t1_id and t2.t2_id as primary keys. They are related by table t3 with columns t3.t1_id and t3.t2_id, respectively. Using LINQ I get an EntitySet<t3> on class t1 and t2, but what I want is an EntitySet<t2> on class t1 and EntitySet<t1> on class t2. How do I do this?

我有两个表,t1和t2,其中t1.t1_id和t2.t2_id为主键。它们分别通过表t3与列t3.t1_id和t3.t2_id相关联。使用LINQ我在类t1和t2上得到一个EntitySet ,但我想要的是类t1上的EntitySet 和类t2上的EntitySet 。我该怎么做呢?

1 个解决方案

#1


0  

Try this:

From Mitsu's Blog on MSDN

来自Mitsu的MSDN博客

Update: I forgot to link part 2 of the blog entry: Second Part

更新:我忘记链接博客条目的第2部分:第二部分

#1


0  

Try this:

From Mitsu's Blog on MSDN

来自Mitsu的MSDN博客

Update: I forgot to link part 2 of the blog entry: Second Part

更新:我忘记链接博客条目的第2部分:第二部分