I am working on a MVC 5 application. I have a method in the controller that accepts 5 parameters, one of which is a integer array. This array would be used to retrieve specific information from the db based on the values contained in it.
The code for the controller method is shown below:
public JsonResult varyByStudyPeriod(int buildingId, int baselineLocationId, int baselineStandardId, int baselinePeriod, int [] altPeriod)
{
var data = from r in db.ResidentialDatas
where r.BuildingId == buildingId
&& r.LocationId == baselineLocationId
&& r.StandardId == baselineStandardId
&& r.Year == baselinePeriod
//&& altPeriod.Contains(r.Year)
select new { r.LCC, r.Year };
return Json(data, JsonRequestBehavior.AllowGet);
}
Year is simply just integers from 1 to 40 in the db.
However, the commented line is where the Json request fails. Is it possible to guide me in the right direction?
The url for the JSON request is shown below. The format seems to be the issue as the method does not retrieve the information requested.
/ResidentialBuilding/varyByStudyPeriod?buildingId=1&baselineLocationId=1
&baselineStandardId=1&baselinePeriod=1&**altPeriod=2,3**
altPeriodor is it null?