我是ASP.NET新手,似乎无法找到我的问题的答案。VB.NET ASP.NET检索列表的数据库
我想在我的数据库中检索一个表格列表。
我发现了一种在C#中做到这一点的方法,但我需要在Viusal Basic中做到这一点。
private List<Country> PopulateCountry()
{
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
return dc.Countries.OrderBy(a => a.CountryName).ToList();
}
}
这是从C#代码示例中,我试图转换成VB.net,但我不断收到此错误信息,并且不能找出原因。
Private Function GetListOfCountries() As List(Of Country)
Using dc As New MyDatabaseEntities
Try
Dim countryList = (From p In dc.Counties Order By p.CountryName
Ascending
Select p)
Return countryList.ToList()
Catch ex As Exception
Return Nothing
End Try
End Using
End Function
在Return countryList.ToList()
线我得到这个错误
Value of type 'List(Of Country)' cannot be converted to 'List(Of Country)'.
任何帮助将非常感激。谢谢!
你有一个错字,请检查您的图片 - '名单(共县)'VS'名单(国家)' – Fabio