I have the following code to select all counties given a stateid from a counties table.
Public Shared Function GetCountiesfromState(statename As String) As List(Of String)
Dim context As New Model.teckEntities()
Dim query = From c In context.counties Where c.stateId = 7 Select c
Return query.ToList()
End Function
I get any error that query is returning a list of model. any thoughts on where the error lies?
If there is a
Name(orTitle) field on the County entity, it should be as simple as:In your code above you were selecting the
cwhich, is a County entity, not necessarily a string property. By selectingc.Name(orc.Title) instead, you’ll be building a list of strings instead of a list of county entities.Cheers.