我有这个查询,而且我无法转换为lambda表达式
SELECT [dbo].[Prospects].[Id]
,[UserId]
,[NewId]
,[dbo].[Prospects].[Status]
FROM [dbo].[Prospects] join [dbo].[User] on [dbo].[User].Id = [dbo]. [Prospects].UserId
where [dbo].[Prospects].NewId = 3 and [dbo].[User].IsActive = 1
这就是我得到的,但它不起作用
var result = Workspace.Prospects.Join
(Workspace.Users, pros => pros.UserId,
use => use.Id, (pros, use)
=> new { Prospect = pros, User = use}).Where
(both => both.User.IsActive == true && both.Prospect.NewId == idVacante)
.OrderBy(both => both.Prospect.Id).AsEnumerable().ToList();
List<Prospect> prospects = result.Cast<Prospect>().ToList();
答案 0 :(得分:0)
这并不难。您可以在加入表之前过滤表
var result = Workspace.Prospects.Where(x=> x.NewId == 3)
.Join(Workspace.Users.Where(x => x.IsActive == 1),
p => p.UserId,
u => u.Id,
(p, u) => new { p.Id, p.UserId, p.NewId, p.Status })