0
我有這個linq查詢看起來不錯,尚未測試。 但我想知道爲什麼我不能把語句放在單獨的行上。 如果我嘗試,我得到和意外的標記錯誤,並且c和b成爲 無法訪問DUT以保護級別 工作查詢Linq查詢語法
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
因爲這是VB.Net語法。把'_'放在行尾,它會工作。 – asawyer
@asawyer謝謝你的作品,如果你想要檢查,請在下面發帖;) –
Dave的回答很好。 – asawyer