I'm not entirely sure how to define this question but basically I'm developing an ASP.Net application where I am generating a JsonResult
called IndexJson
.
My code is as follows:
public JsonResult IndexJson()
{
var contacts = (from x in db.ContactSet
select new
{
x.AccountId,
x.FirstName,
x.LastName,
x.FullName,
x.JobTitle,
x.ParentCustomerId,
x.EMailAddress1,
x.Telephone1,
x.MobilePhone,
x.Fax,
x.GenderCode,
x.BirthDate
}).ToList();
return Json(contacts, JsonRequestBehavior.AllowGet);
}
This works well at returning the following JSON:
[{/*contact info*/}, {/*contact info*/}, {/*contact info*/}, ...]
But now I want to return the following JSON (hard-coded for now, I will change the values later):
{
"current": 1,
"rowCount": 10,
"rows": [{/*contact info*/}, {/*contact info*/}, {/*contact info*/}, ...],
"total": 1123
}
How can I adapt my code to do that?