This project is read-only.

Can we use an array, list, ienumerable, or similar as Action function parameter?

Topics: ASP.NET Web API
Feb 28, 2013 at 8:12 PM
I'm trying to send a list of strings as a parameter in the content of a call to an Action but I'm not having any luck. I can get pretty much any other datatype to work, just not an array, list, or anything similar.
I have an EntitySetController(Of Computer, Integer) with an Action function with the following signature...
Public Function RunCommand(key As Integer, parameters As OData.ODataActionParameters) As Integer
and the following code when building the model...
Dim computer As EntityTypeConfiguration(Of Computer) = modelBuilder.EntitySet(Of Computer)("Computers").EntityType
Dim runCommand As ActionConfiguration = computer.Action("RunCommand")
runCommand.Parameter(Of List(Of String))("Params")
runCommand.Returns(Of Integer)()
Am I missing something?
Feb 28, 2013 at 8:29 PM

In the definition of the action, you would need to use the following...Note the 'CollectionParameter'

runCommand.CollectionParameter(Of List(Of String))("Params")

Feb 28, 2013 at 8:35 PM
Hi Kiran,

Thanks for the response, it lead me in the right direction, however, rather than it being
runCommand.CollectionParameter(Of List(Of String))("Params")
it seems it should be...
runCommand.CollectionParameter(Of String)("Params")
I can't believe I overlooked CollectionParameter, I'm so oblivious some times.
Feb 28, 2013 at 8:38 PM
Sorry...I should have mentioned before...I am poor in VB.NET language :-)