我有以下 3 个查询。第一个工作正常,但后两个抛出一个错误,说range varible Year (or semester, respectively) hides a variable in an enclosing block or a range variable previously defined in the query expression.
我不是最擅长编码,所以我在 MSDN 上查找的任何内容都让我更加困惑。这里的任何帮助都会很棒。
Dim compulsoryModule = (From mods In db.Modules
Join deg In db.Degrees On mods.Degree_code Equals deg.Degree_code
Where deg.Degree_code = degree And mods.Compulsory = True And mods.Level = 1
Select mods.Module_code)
Dim year = (From mods1 In db.Modules
Join deg1 In db.Degrees On mods1.Degree_code Equals deg1.Degree_code
Where deg1.Degree_code = degree And mods1.Compulsory = True And mods1.Level = 1
Select mods1.Year)
Dim semester = (From mods In db.Modules
Join deg In db.Degrees On mods.Degree_code Equals deg.Degree_code
Where deg.Degree_code = degree And mods.Compulsory = True And mods.Level = 1
Select mods.Semester)
错误只会在查询中抛出,select mods1.year
并且数据库select mods.semester
中的 NByear
已更改为 1。这只是我试图解决问题。如果我删除它们,它不会更改代码。