我有2个表,我想使用Lambda语句(不是Linq而是Lambda)加入它们.
这是我需要的查询:
SELECT
c.*
FROM
board as b
LEFT JOIN category as c ON
b.cid = c.cid
WHERE
b.bid = 1
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
假设board是一个数据集/变量,category是另一个数据集/变量,那么我想要一些像board.Join(category).Where(b => b.bid == c.cid)(我知道这是错的,但只是所以你知道我在寻找什么,非常感谢你的帮助
如果您的意思是方法语法而不是linq的查询语法,那么您可以这样做
var results = context.boards.Where(b => b.bid == 1)
.DefaultIfEmpty()
.Join(context.categories,
b => b.bid,
c => c.cid,
(b, c) => c);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16916 次 |
| 最近记录: |