我在将 LINQ 语句输出到用 Visual Studio 2010 编写的 ASP.NET 列表中时遇到问题。下面的函数尝试在其数据源中搜索相关 DVD 并输出一条记录:
Public Function GetDVD(ByVal id As Integer) As DVDRaritiesDVDs _
Implements IDVDDAO.GetDVD
Dim DVD = From DVDList In _context.DVDRaritiesDVDs _
Where DVDList.DVDID = id Select DVDList
Return DVD.ToList().First()
End Function
但是当我尝试这样加入它时:
Public Function GetDVD(ByVal id As Integer) As DVDRaritiesDVDs _
Implements IDVDDAO.GetDVD
Dim DVD = From DVDList In _context.DVDRaritiesDVDs _
Join Category In _context.DVDRaritiesCategories _
On Category.CategoryID Equals DVDList.CategoryID _
Where DVDList.DVDID = id Select DVDList, Category
Return DVD.ToList().First()
End Function
构建代码时它给了我以下错误:
错误 1 类型“(第 23 行)”的值无法转换为“DVDRarities.Data.DVDRaritiesDVDs”。C:\Users\a9010799\Projects\DVDRarities\DVDRarities.Data\DAO\DVDDAO.vb 24 16 DVDRarities.Data
请有人指出我哪里出错了,以便我可以在一份声明中做到这一点?