0
我有以下代码来选择县县表给出的所有县的状态ID。实体框架检索数据作为列表(字符串)
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
我得到任何错误,查询返回模型列表。关于错误在哪里的任何想法?
你打算如何将一个国家“转换”为一个字符串?您需要选择其中一个字符串属性:'Where c.stateId = 7选择c.Name'等。或者返回整个国家列表'GetCountiesfromState(statename As String)As List(Of Country)' – nemesv
好点。我改变了列表(县)的列表,但是我的下拉列表中没有任何内容。我将列表设置为数据源并对其进行数据绑定。 – dinotom