Thanks @robesz - there were some subtleties in creating parameterized odata actions in .net and this is what has been plaguing me (I have tried actions before just couldn't get it to work), but this time I got it:
[Queryable]
[HttpPost]
public IQueryable<Airport> GetAirportsWithinRadius([FromBody] ODataActionParameters parameters)
{
if (!ModelState.IsValid)
{
throw new HttpResponseException(HttpStatusCode.BadRequest);
}
var radius = (int)parameters["radius"];
var airportId = (int)parameters["airportId"];
var resultAirports = GetAirportsWithinRadius2(airportId, radius);
return resultAirports;
}
ActionConfiguration getAirportsWithinRadius = modelBuilder.Entity<Airport>().Collection.Action("GetAirportsWithinRadius");
getAirportsWithinRadius.Parameter<int>("airportId");
getAirportsWithinRadius.Parameter<int>("radius");
getAirportsWithinRadius.ReturnsCollectionFromEntitySet<Airport>("Airports");
With this in place I can now do the following with jaydata:
var service = $data.initService("http://localhost:2663/odata");
return service.then(function (db) {
airports = db.Airports.GetAirportsWithinRadius(2112,50);
airports.filter("it.Abbrev== a", {a: 'C44'}).forEach(function(a){console.log(a.Abbrev)});
});
I am jumping up and down in joy :)