L
L
lucky42021-07-15 10:40:06
ASP.NET
lucky4, 2021-07-15 10:40:06

How to display multiple entities in one query?

For example, I need to post:

/api/something?somethingNames=Name&somethingNames=Surname


Now it works in such a way that you can't output more than one just like this:
/api/something?somethingNames=Name

Now it outputs like this:
{
  "Name": {
    "1": {
      "id": 1
    }
    //...
  }
}


Here's something like this you need:
{
  "Name": {
    "1": {
      "id": 1
    }
    //...
  },
  "Surname": {
    "1": {
      "id": 1
    },
    // ...
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-07-15
@lucky4

You can get a collection of parameters in a controller method like this:

public ActionResult GetSomething([FromQuery] string[] somethingNames)
{
    ...
}

If you are talking about it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question