0
當我執行下面的代碼我收到錯誤消息:LINQ到實體不支持的方法... System.Object的CompareObjectEqual
LINQ到實體無法識別方法「System.Object的CompareObjectEqual( System.Object,System.Object,Boolean)'方法,並且此方法不能轉換爲存儲表達式。
它似乎發生在PCstudent中的每行第2行。
Protected Sub btnPushSemester_Click(sender As Object, e As EventArgs) Handles btnPushSemester.Click
Dim dbPC As New Campus6Entities
Dim dbContext As New pbu_housingEntities
Dim getOccupants
Dim thisYear As String
Dim thisTerm As String
Using dbContext
Dim get_Year = From p In dbContext.Configs _
Where p.Description = "year" _
Select p
Dim get_Term = From p In dbContext.Configs _
Where p.Description = "term" _
Select p
thisYear = get_Year.First.textValue
thisTerm = get_Term.First.textValue
getOccupants = From p In dbContext.Residents _
Where p.semester = thisTerm _
Where p.year = thisYear _
Select p
Using dbPC
For Each row In getOccupants
Dim student_info = row
Dim people_id = student_info.people_code_id
Dim building_code = student_info.Building1.building_code
Dim room = student_info.Room1.room1
Dim PCstudent = From r In dbPC.RESIDENCies _
Where r.PEOPLE_ID = people_id _
Where r.ACADEMIC_YEAR = thisYear _
Where r.ACADEMIC_TERM = thisTerm _
Select r
For Each row2 In PCstudent
Dim student_info2 = row2
student_info2.DORM_BUILDING = building_code
student_info2.DORM_ROOM = room
student_info2.RESIDENT_COMMUTER = "R"
student_info2.DORM_CAMPUS = "O000000001"
dbPC.SaveChanges()
Next
Next
End Using
End Using
End Sub
你會推薦以什麼方式來做這件事? – davemackey 2011-05-31 23:03:20
實際上,Steve的定義中存在一個問題:對於Person來說,RBAR(通過痛苦行來排)往往是最容易理解的,但對於數據庫服務器來說卻是最困難的方式。相反的是使用集合。 .Net中的數據集或甚至強類型的類和領主知道有多少其他方式來表示相關數據組。 – 2011-05-31 23:14:00
解決* *問題的方法,而不是你問過的問題是在列表中工作。如果您使用的是實體框架,那麼我確定該實體接受列表/ IEnumerable作爲源。您只需選擇您需要的佔用者,根據需要更新其各自的屬性,然後將整個設置傳回EF以更新數據庫。 – 2011-05-31 23:16:28