I have a table (Rooms) which contains a number of rows. Each row represents a room and each room needs to exist twice (once for fall, once for spring semester). Sometimes when folks add a room they only add it for one semester. I’m working on a process that will synchronize the rooms between semesters.
First I’ve pulled two queries, one that gets all of the rooms with fall in their semester column and one that gets all of the rooms with spring in their semester column, like so:
Dim getFallRooms = (From p In dbContext.Rooms _
Where p.semester = "Fall" _
Select p)
Dim getSpringRooms = (From p In dbContext.Rooms _
Where p.semester = "Spring" _
Select p)
The results will each contain multiple rows with the following columns: id, building, room, occupant, and semester.
What I want to do is something like this (pseudo):
For Each row in getFallRooms
If row.building and row.room not in getSpringRooms Then
' Code to add new row with fall as the semester.
End If
Next
Any suggestions on how I can make this into actual, workable code?
1 Answer