2

I have a $scope object as bellow

$scope.array=[{"ID":"1","ID":"2","ID":"3"}];

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?

2
  • 1
    any attempt in server side ? Commented May 25, 2016 at 3:11
  • That is the thing I want to know. Can I pass this array values using a List<> in the Model? Commented May 25, 2016 at 3:13

1 Answer 1

1

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+"')";

}
Sign up to request clarification or add additional context in comments.

2 Comments

If I'm using a model with multiple attributes public class model{ public int ID {get;set;} public int age{get;set;} } how can I get the values?
this value have to in json object otherwise it won't pass. It will catch those which property mentioned both in class and json object @TharinduSenanayake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.