我有这个看起来不错的 linq 查询,尚未测试。但我想知道为什么我不能将 And 语句放在单独的行上。如果我尝试我得到和意外的令牌错误,并且由于保护级别工作查询而 c 和 b 变得无法访问
Dim result =
From b In context.H_Beneficiary
Join e In context.Employees
On b.EmployeeId Equals (e.EmployeeId)
Join c In context.Companies
On e.AncillaryId Equals (c.CompanyId)
Where e.AncillaryId.Equals(iPerId) And c.AncillaryId.Equals(iCompanyId) And ((b.EndDate Is Nothing) Or (b.EndDate.Equals(DateTime.Today)))
Select b.EnterTime
Return CDate(result)
Return CDate(result)
所需查询
Dim result =
From b In context.H_Beneficiary
Join e In context.Employees
On b.EmployeeId Equals (e.EmployeeId)
Join c In context.Companies
On e.AncillaryId Equals (c.CompanyId)
Where e.AncillaryId.Equals(iPerId)
And c.AncillaryId.Equals(iCompanyId)
And ((b.EndDate Is Nothing) Or (b.EndDate.Equals(DateTime.Today)))
Select b.EnterTime