我有以下代码在提交行上抛出错误。它说data type(s) of the type parameters ) in method cannot be inferred from these arguments
。正如我(我认为)明确说明数据类型肯定它应该工作。 userID
通过另一个查询直接从数据库中获取。
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)
Dim take As New Take With _
{.User_Number = userId, _
.Degree_code = degree, _
.Module_code = compulsoryModule, _
.Year = years, _
.Semester = semesters}
db.Takes.InsertAllOnSubmit(take)
这是给出错误的最后一行
答案 0 :(得分:1)
好的修好了。问题是我正在返回多个记录并试图将它们作为一个新记录输入,从而导致错误。我将我的提交部分修改为我的代码的for循环,以迭代结果并单独添加它们。我使用的循环是:
For Each moduleCode As String In compulsoryModules
Dim take As New Take With _
{.User_Number = userId, _
.Degree_code = degree, _
.Module_code = moduleCode, _
.Year = years, _
.Semester = semesters}
db.Takes.InsertOnSubmit(take)
希望这有助于其他人。