c# - odata v4 using 2 parameter -
i want pass 2 parameter controller , run sql-function try , googled lot resources no luck,
anyone give me hints?
basically follow web api , odata- pass multiple parameters
when using builder.function
compiler keep tell me no extension method found.
package.config
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="entityframework" version="6.1.3" targetframework="net452" /> <package id="entityframework.functions" version="1.4.0" targetframework="net452" /> <package id="microsoft.aspnet.odata" version="6.0.0" targetframework="net452" /> <package id="microsoft.aspnet.webapi" version="5.2.3" targetframework="net452" /> <package id="microsoft.aspnet.webapi.client" version="5.2.3" targetframework="net452" /> <package id="microsoft.aspnet.webapi.core" version="5.2.3" targetframework="net452" /> <package id="microsoft.aspnet.webapi.odata" version="5.3.1" targetframework="net452" /> <package id="microsoft.aspnet.webapi.webhost" version="5.2.3" targetframework="net452" /> <package id="microsoft.codedom.providers.dotnetcompilerplatform" version="1.0.0" targetframework="net452" /> <package id="microsoft.data.edm" version="5.6.0" targetframework="net452" /> <package id="microsoft.data.odata" version="5.6.0" targetframework="net452" /> <package id="microsoft.extensions.dependencyinjection" version="1.0.0" targetframework="net452" /> <package id="microsoft.extensions.dependencyinjection.abstractions" version="1.0.0" targetframework="net452" /> <package id="microsoft.net.compilers" version="1.0.0" targetframework="net452" developmentdependency="true" /> <package id="microsoft.odata.core" version="7.0.0" targetframework="net452" /> <package id="microsoft.odata.edm" version="7.0.0" targetframework="net452" /> <package id="microsoft.spatial" version="7.0.0" targetframework="net452" /> <package id="newtonsoft.json" version="6.0.4" targetframework="net452" /> <package id="system.spatial" version="5.6.0" targetframework="net452" /> </packages>
my webapiconfog.cs
using microsoft.odata.edm; using newtonsoft.json; using newtonsoft.json.serialization; using system.web.http; using system.web.http.odata.builder; using system.web.http.odata.extensions; using wcod; using wcod.model; namespace wcod { public static class webapiconfig { public static void register(httpconfiguration config) { // web api configuration , services odatamodelbuilder builder = new odataconventionmodelbuilder(); // config.count().filter().orderby().expand().select().maxtop(null); var json = config.formatters.jsonformatter; json.serializersettings.preservereferenceshandling = newtonsoft.json.preservereferenceshandling.objects; config.formatters.remove(config.formatters.xmlformatter); config.formatters.remove(config.formatters.xmlformatter); config.formatters.jsonformatter.serializersettings.formatting = formatting.indented; config.formatters.jsonformatter.serializersettings.contractresolver = new camelcasepropertynamescontractresolver(); // var json = config.formatters.jsonformatter; // builder.entityset<booking>("bookings"); builder.entityset<livebooking>("livebookings"); builder.entityset<timemarker>("timemarkers"); builder.entityset<bookinginfo>("bookinginfoes"); builder.entityset<livebookingbytype>("livebookingbytypes"); config.maphttpattributeroutes(); config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional } ); config.routes.mapodataserviceroute("odata", "odata/v4", builder.getedmmodel()); // config.mapodataserviceroute( routename: "odataroute", routeprefix: "odata/v4", model: builder.getedmmodel()); } } }
you should use system.web.odata.builder
instead of system.web.http.odata.builder
. should in package microsoft.aspnet.odata
.
if .getedmodel()
throws exception there might wrong definition, not using.
Comments
Post a Comment