I'm using following code in web api to return json:
So, here is dto class. But it's not clear how to map it to result.
public class grafikresult
{
int kodg { get; set; }
string name { get; set; }
DateTime data { get; set; }
byte pax { get; set; }
byte ch { get; set; }
}
Here is controller code:
// GET api/Grafik/5
public IHttpActionResult GetGrafik(int id)
{
PhuketEntities db = new PhuketEntities();
xTourist t = db.xTourist.Find(id);
var result = from a in db.Grafik
join b in db.Exc on a.Excursion equals b.Kod
join c in db.Dates on a.Kodd equals c.kodd
join d in db.Staff on a.Guide equals d.Kod
where c.Date > t.ArrDate && c.Дата < t.DepDate
select new { kodg = a.Kodg, name = d.Name, data = c.Date, pax = t.Pax, ch = t.Child };
return Ok(result);
}
This returns new json like that:
{
"$id": "1",
"$values": [{
"$id": "2",
"kodg": -1643387437,
"name": null,
"data": "2014-02-07T00:00:00",
"pax": 2,
"ch": 0
}, {...}]
}
How should I change web api controller code to be able get this json:
{
"$id": "1",
"kodg": -1643387437,
"name": null,
"data": "2014-02-07T00:00:00",
"pax": 2,
"ch": 0
}, {...}
}