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