I have a list like this below:
[
{
"hospital_Name": "Abbey View Medical Centre"
},
{
"hospital_Name": "Abingdon Mental Health Centre"
},
{
"hospital_Name": "Accrington Victoria Community Hospital"
}
]
but i need to give an object name of this array list,but it is not coming..
What I have tried:
I am giving the code below
Controller Code:
[Route("fetchNHSHospitalsRecords"), HttpGet]
public IHttpActionResult NHSHospitalsRecords()
{
try
{
var result = db.FetchNHSHospitalsRecords().Select(h => h.Hospital_Name).ToArray();
// var result = db.FetchNHSHospitalsRecords();
return Ok(result);
}
catch (Exception e)
{
return InternalServerError(e);
}
}
Function Return Code:
public List<nhshospitals> FetchNHSHospitalsRecords()
{
using (var con = GetDbConnection())
{
string query = "select distinct Hospital_Name from NHSHospitals WHERE Hospital_Name IS NOT NULL Order By Hospital_Name"; List<nhshospitals> objlstcstr = con.RunQuery<nhshospitals>(query);
return con.RunQuery<nhshospitals>(query);
}
}
Plz Help..