我试图用这段代码做的是从我的数据库中选择数据信息并将结果查询放在一个列表中,然后将结果添加到我稍后将使用的新列表中......但这给出了我的错误:
无法将类型的对象
WhereSelectListIterator< jTableSampleDatabaseLayer.Hik.JTable.Models.Concour, VB$AnonymousType_0<string, int?, int?, DateTime, int, int, string, int?>>
转换为类型IEnumerable<jTableSampleDatabaseLayer.Hik.JTable.Models.Concour>
Imports System.Collections.Generic
Imports System.Text
Imports jTableSampleDatabaseLayer.Hik.JTable.Models
Namespace Hik.JTable.Repositories.Memory
Public Class MemoryData
Dim x As jTableSampleDatabaseLayer.totofootEntities = New jTableSampleDatabaseLayer.totofootEntities
Public Function ListeConcours() As MemoryDataSource
Dim dataSource = New MemoryDataSource()
Dim liste As List(Of Concour) = x.Concours.ToList()
Dim ccrs = From concours In liste Select concours.numero_concours, concours.numero_type, concours.numero_nature, concours.date_de_sortie, concours.nbre_matchs, concours.nbre_rangs, concours.titre_concours, concours.numero_etape
dataSource.Concours.AddRange(ccrs)
Return dataSource
End Function
End Class
End Namespace
如您所见,我可能真的不知道如何解决这个问题。有没有人知道我可能做错了什么以及如何解决它?
这是类 memorydatasource :
`Imports System.Collections.Generic
导入 jTableSampleDatabaseLayer.Hik.JTable.Models
命名空间 Hik.JTable.Repositories.Memory
Public Class MemoryDataSource
Public Property Types As List(Of Type)
Public Property Concours As List(Of Concour)
Public Property Natures As List(Of Nature)
Public Property Etapes As List(Of Etape)
Public Sub New()
Types = New List(Of Type)()
Natures = New List(Of Nature)()
Etapes = New List(Of Etape)()
Concours = New List(Of Concour)()
End Sub
End Class
结束命名空间
`