odata - how do I use the $select from ODataQueryOptions with a seporate data layer? -


i trying $select portion of odataqueryoptions working business layer , can't seem noodle way (fyi: placing ef query in controller not option)..

here odatacontroller method

public async task<ihttpactionresult> get(guid propertyid, odataqueryoptions<highschoolviewmodel> odataoptions)     {         // validate query.         try         {             odataoptions.validate(_validationsettings);         }         catch (odataexception ex)         {             return badrequest(ex.message);         }          ienumerable<highschoolviewmodel> returndata = await _service.odatasearchasync(propertyid, odataoptions);         return ok<ienumerable<highschoolviewmodel>>(returndata);     } 

and here business layer/method

public async task<ienumerable<highschoolviewmodel>> odatasearchasync(guid propertyid, odataqueryoptions<highschoolviewmodel> queryoptions)         {             using (dbcontext context = new lamscontext())             {                 var query = queryoptions.applyto(context.propertyhighschools.where(hs => hs.propertyid == propertyid)                      .project().to<highschoolviewmodel>());                 return await ((iqueryable<highschoolviewmodel>)query).tolistasync();             }         } 

this works great except $select (and expand that's "out of scope").

obviously when applyto() runs changes iqueryable returning anonymous type, , there blows when query executed. tried returning ienumerable type wouldn't matter, when odata can't seem handle , starts spitting out 406 errors.

in scenario, change controller inherent form apicontroller, , return

result.asqueryable(); 

this may work around $select.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -