Tharindu Senanayake Tharindu Senanayake - 1 year ago 72
SQL Question

Passing multiple array values to a web api controller using a single model attribute

I have a $scope object as bellow


What I want to do is pass these values to the following SQL query

Select * from table where ID in("Here I need the above 3 values one after another")

How can I do this?

Answer Source

Create a class

public class myId {
  public int ID {set;get;}

pass it to web api

public void submitID(List<myId> ids){
  // do rest of the things
  var id = string.Join(",", ids.Select(x => x.ID).ToArray());
  var query="Select * from table where ID in('"+id+"')";