我通常會在C#中執行此操作,但由於我必須在此特定程序集中獲得此代碼,因爲這是vb .net一,我卡住了。如何在Linq查詢中使用++的vb等效項來投射新類型
這裏是我的LINQ查詢:
Dim i As Integer = 0
Dim oldAndCurrentIntersectionOnNames = From currentApplicant In currentApplicants _
Group Join oldApplicant In oldApplicants _
On _
New With {Key .FirstName = currentApplicant.FirstName, _
Key .LastName = currentApplicant.LastName} _
Equals _
New With {Key .FirstName = oldApplicant.FirstName, _
Key .LastName = oldApplicant.LastName} Into applicants = Group _
From applicant In applicants.DefaultIfEmpty(New ApplicantNameDetails()) _
Select New ApplicantNameDetails() With _
{ _
.Index = i+=1, _
.FirstName = CStr(IIf(Not currentApplicant.FirstName Is Nothing, currentApplicant.FirstName, Nothing)), _
.OldFirstName = CStr(IIf(Not applicant.FirstName Is Nothing, applicant.FirstName, Nothing)), _
.LastName = CStr(IIf(Not currentApplicant.LastName Is Nothing, currentApplicant.LastName, Nothing)), _
.OldLastName = CStr(IIf(Not applicant.LastName Is Nothing, applicant.LastName, Nothing)) _
}
你會看到的.index = I + = 1
這是我試圖做什麼,我想在C#中相當愉快地做(即指數=我在++)。不幸的是,VB編譯器不喜歡這樣。
有沒有人有任何建議,我怎麼會在VB中做到這一點。
在此先感謝
Doh! '_必須......得到......它......要......工作......在......一個......單片......查詢_「談論獲得隧道視野並忽視分而治之!這很有用,非常感謝! (選擇缺少一個右括號btw) – Weevie 2011-05-04 08:39:04