ODATA Consume Service Operation from C# ASP.NET 4.0 -
i connecting odata service via c# asp.net application, has service operations such as:
getitems(int? itemid, double? price)
i can consume without issues in browser, e.g.
http://api.mycompany.com/companycatalogue/getitems?itemid=4
i understand how use linq entities consume odata service, can't find decent explanation of how consume service operations 1 above in c#. have made web reference service in visual studio solution.
so far, have usual consuming of data:
using companycatalogue; //my web reference ... protected void page_load(object sender, eventargs e) { companycatalogueentities datacontext = new companycatalogueentities (new uri("http://api.mycompany.com/companycatalogue/")); var result = in datacontext.items select i; //just example //this problems var operationresults = companycatalogue.getitems(6, 20.5); //i made }
any pointers?
ok, got answer:
using companycatalogue; //my web reference ... protected void page_load(object sender, eventargs e) { companycatalogueentities datacontext = new companycatalogueentities(); dataservicequery<getitemsresult> q = datacontext.createquery<getitemsresult>("getitems") .addqueryoption("paramname", 6) .addqueryoption("paramname2", 20.5); list<getitemsresult> items = q.execute().tolist(); }
Comments
Post a Comment