我有以下代码:
Using dbContext As pbu_housingEntities = New pbu_housingEntities
' First, delete all current records associated with the specified semester.
Dim delete_old = (From p In dbContext.Residents _
Where p.semester = txtDestSemester.Text _
Where p.year = txtDestYear.Text _
Select p)
dbContext.Residents.DeleteObject(delete_old)
dbContext.SaveChanges()
End Using
但它不起作用。它会引发无法转换类型为“System.Data.Objects.ObjectQuery”的对象错误。有什么想法吗?
我要做的就是获取具有指定条件的行列表,然后删除所有返回的行。