Reputation: 41
I am trying to create an instance of ODataQueryContext
which requires an EdmModel
reference. I am attempting to get the Model
from ODataProperties()
which is a method call off of the HttpRequestMessage
object.
var orderBy = new OrderByQueryOption("ColumnName desc", new ODataQueryContext(Request.ODataProperties().Model, typeof(MyType)));
It seems that if I use the namespace using System.Web.Http.OData.Extensions;
as opposed to using System.Web.OData.Extensions;
the Model property is available from ODataProperties()
. However, I am using the newer version (OData v4) namespaces, for other references in my program.
After doing some research I determined that with OData v4, they moved everything from Web.Http.OData.*
namespaces, to Web.OData.*
namespaces. I am assuming that I need to be consistent in using either the new or old namespaces, and I was not successful attempting to mix them.
Does anyone know how to get the Model
property from ODataProperties()
without using the older Web.Http.OData
namespaces?
Upvotes: 2
Views: 1974
Reputation: 1661
In ASP.NET Core 3.1, package Microsoft.AspNetCore.OData, most values under Request.ODataProperties()
are now under Request.ODataFeature()
.
Upvotes: 3
Reputation: 602
To anyone still having trouble with this (I ended-up here from a MS OData tutorial) request.ODataProperties().Model
has changed to request.GetModel()
( HttpRequestMessageExtensions in namespace Microsoft.AspNet.OData.Extensions in assembly Microsoft.AspNet.OData). Also request.ODataProperties().PathHandler
has changed to request.GetPathHandler()
.
Upvotes: 9