表名:user
字段:Id(主键)
Code(编号)
RecId(外键,关联Id)
select Code,(select COUNT(*) from user where RecId = u.Id) as RecCount from user as u;

求帮忙把sql 转 一下lambda,lambda不知道怎么写出来,跪求
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- threenewbee 2020-08-21 22:51关注
user.GroupJoin(user, x => x.Id, x => x.RecId, (x, y) => new {x, y}).Select(x => new { RecCount = x.y.Count(), x.x.Code })
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报