Tharindu Senanayake Tharindu Senanayake - 2 years ago 110
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+"')";

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download