linq to sql:连接同一表中的多个列

编程入门 行业动态 更新时间:2024-10-26 22:20:37
本文介绍了linq to sql:连接同一表中的多个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何通过Linq内部联接来自同一表的多个列?

How do I inner join multiple columns from the same tables via Linq?

例如: 我已经有了这个...

For example: I already have this...

join c in db.table2 on table2.ID equals table1.ID

我需要添加这个...

I need to add this...

join d in db.table2 on table2.Country equals table1.Country

推荐答案

您可以将查询放在Where子句中,而不使用联接运算符.

You can put your query inside a Where clause instead of using the join operator.

join运算符在VB.NET中支持多个子句,但在C#中不支持.

The join operator supports multiple clauses in VB.NET, but not C#.

或者,您可以使用ANSI-82风格的"SQL"语法,例如:

Alternatively, you can use the ANSI-82 style of 'SQL' syntax, e.g.:

from t1 in table1 from t2 in table1 where t1.x == t2.x && t1.y == t2.y

更多推荐

linq to sql:连接同一表中的多个列

本文发布于:2023-10-28 13:49:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   linq   sql   一表中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!