I am new to AP.Net MVC services and Trying to create a web service where we give the array of input which will connect to oracle database and return the query (the array of input needs used in the filter)result. I am trying no to use the entity data model and giving the POCO classes in Model classes.So what I tried is to create a simple controller which selectentire data from the database
public class TestOraConnController : ApiController
{
public string Get(int id)
{
var strQuery = @"Select PRIO_CATEGORY_ID as PRIO,LANG_ID as LANG, REC_DATE as REC, REC_USER as RECUSER, RFCH_ID as RFCH,DESCR,COL_DESCR AS COL,ROW_DESCR as DROW,ABBR from STCD_PRIO_CATEGORY_DESCR where REC_USER =" +id;
OracleConnection dbConn = new OracleConnection("DATA SOURCE=ABC;PASSWORD=ABCD;PERSIST SECURITY INFO=True;USER ID=ABC");
dbConn.Open();
OracleCommand selectCommand = new OracleCommand(strQuery, dbConn);
OracleDataAdapter adapter = new OracleDataAdapter(selectCommand);
DataTable selectResults = new DataTable();
adapter.Fill(selectResults);
dbConn.Close();
return JsonConvert.SerializeObject(selectResults);
}
So the result looks
"[{\"PRIO\":1,\"LANG\":1,\"REC\":\"2011-10-23T20:32:18\",\"RECUSER\":1,\"RFCH\":null,\"DESCR\":\"Internal Study\",\"COL\":\"Internal Study\",\"DROW\":\"Internal Study\",\"ABBR\":\"Intern\"},{\"PRIO\":1,\"LANG\":2,\"REC\":\"2011-10-23T20:32:18\",\"RECUSER\":1,\"RFCH\":null,\"DESCR\":\"Internal Study\",\"COL\":\"Internal Study\",\"DROW\":\"Internal Study\",\"ABBR\":\"Intern\"},{\"PRIO\":2,\"LANG\":1,\"REC\":\"2011-10-23T20:32:31\",\"RECUSER\":1,\"RFCH\":null,\"DESCR\":\"Client Study\",\"COL\":\"Client Study\",\"DROW\":\"Client Study\",\"ABBR\":\"Client\"}]"
Now if I need to give the array of input parameter I am how to interate through the array of parameters to select. I understand we give the
public string get( int []d)
But not sure how we need to change the query. Any hep is greatly appreciated.