i have issue returning a list in a web method. here is the code
<WebMethod()> _
Public Function getTags(para_parents As String) As List(Of getTypeDetailsByParentName_Result)()
Dim context As New PPEntities
Return context.getTypeDetailsByParentName(para_parents).ToList()
context.Dispose()
End Function
the error is
Value of type ‘System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)’ cannot be converted to ‘1-dimensional array of System.Collections.Generic.List(Of SaftyonRoad.getTypeDetailsByParentName_Result)’
Your method declaration indicates you are returning an array of lists:
If you didn’t want to return an array of lists, remove the parenthesis at the end. Then you will just be returning a list.
On an unrelated note, your
context.Dispose()will never get called because you leave the function before that with aReturn. Not cleaning up resources correctly can lead to problems down the road. Typically you could handle this with aUsingstatement: