简体   繁体   English

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

[英]How do I do a many-to-many relationship in LINQ?

I have two tables say, t1 and t2 that have t1.t1_id and t2.t2_id as primary keys. 我有两个表,即t1和t2,它们具有t1.t1_id和t2.t2_id作为主键。 They are related by table t3 with columns t3.t1_id and t3.t2_id, respectively. 它们在表t3中分别与列t3.t1_id和t3.t2_id相关联。 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. 使用LINQ,我在类t1和t2上获得了EntitySet <t3>,但是我想要的是在类t1上的EntitySet <t2>和在类t2上的EntitySet <t1>。 How do I do this? 我该怎么做呢?

Try this: 尝试这个:

From Mitsu's Blog on MSDN 从MSDN上的Mitsu博客

Update: I forgot to link part 2 of the blog entry: Second Part 更新:我忘了链接博客条目的第2部分第二部分

暂无
暂无

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

相关问题 Linq:如何通过多对多关系进行分组? - Linq: how to group by many-to-many relationship? 如何正确地使用瞬态对象更新NHibernate多对多关系? TransientObjectException - How do I properly update an NHibernate Many-to-Many relationship with Transient objects? TransientObjectException 如何在EF Core多对多关系中为删除建模? - How do I model deletion in an EF Core many-to-many relationship? 如何使用Criteria API以多对多关系查询原始类型? - How do I use the Criteria API to query primitive types in a many-to-many relationship? 如何在连接表是架构一部分的 EF Core 中指定多对多关系? - How do I specify a many-to-many relationship in EF Core where the connection table is part of a schema? 如何首先使用Entity Framework代码创建多对多关系? - How do I create a many-to-many relationship with Entity Framework code first? 流畅的NHibernate:如何在关系表上使用其他属性映射多对多关系? - Fluent NHibernate: How do I map Many-to-Many Relationships with additional attributes on the relationship table? 如何仅与一个实体建立多对多关系? - How do I create a Many-to-Many relationship with only one entity? 如何在多对多关系代码第一种样式上设置属性? - How do I set an attribute on a many-to-many relationship code first-style? 如何从多对多关系中获取数据? (剃刀) - How do I grab data from a many-to-many relationship? (razor)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM