Hello everybody. I am trying to learn some VB.NET for my coo-op that starts next week, and for that reason i took my portfolio web site that is on C# and just started to converting it to VB.NET to get familiar with the syntax.
I am sure my problem is simple however i have a hard time solving it. I am trying to grab data with the linq query and then return it as list to bind to the Repeater.
I have the following function:
Public Function getProjects() As List(Of portfolio_website)
Using myPortfolio As New PortfolioDataContext
Try
Dim myProjects = (From p In myPortfolio.portfolio_websites _
Order By p.website_id Descending _
Select New With {.name = p.website_name, .id = p.website_id}).Take(5)
Return myProjects
Catch ex As Exception
Return Nothing
End Try
End Using
End Function
However I am getting an error.
If i would do it in C# then myProjects will be var and in return i will have
return myProjects.ToList();
And it would work fine. However if I try to use ToList() in VB.NET i am getting error that it cannot convert it from ling to sql List to the generic list.
How do i do this convertion in VB.NET ? or maybe there is another way ?
I am decent when it comes to C# however somewhat lost with the VB.NET syntax.