[英]ODataProperties (System.Web.OData.Extensions - OData v4) Missing ''Model' Property
I am trying to create an instance of ODataQueryContext
which requires an EdmModel
reference.我想创建的实例
ODataQueryContext
这需要一个EdmModel
参考。 I am attempting to get the Model
from ODataProperties()
which is a method call off of the HttpRequestMessage
object.我试图从
ODataProperties()
获取Model
,它是HttpRequestMessage
对象的方法调用。
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;
看来,如果我使用
using System.Web.Http.OData.Extensions;
使用命名空间using System.Web.Http.OData.Extensions;
as opposed to using System.Web.OData.Extensions;
与
using System.Web.OData.Extensions;
相反using System.Web.OData.Extensions;
the Model property is available from ODataProperties()
. Model 属性可从
ODataProperties()
。 However, I am using the newer version (OData v4) namespaces, for other references in my program.但是,我使用的是较新版本 (OData v4) 命名空间,用于我程序中的其他引用。
After doing some research I determined that with OData v4, they moved everything from Web.Http.OData.*
namespaces, to Web.OData.*
namespaces.在做了一些研究之后,我确定使用 OData v4,他们将所有内容从
Web.Http.OData.*
命名空间移动到Web.OData.*
命名空间。 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?有谁知道如何从
ODataProperties()
获取Model
属性而不使用旧的Web.Http.OData
命名空间?
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).对于仍然有此问题的任何人(我从 MS OData 教程结束)
request.ODataProperties().Model
已更改为request.GetModel()
( HttpRequestMessageExtensions in namespace Microsoft.AspNet.OData.Extensions in assembly Microsoft.AspNet .O 数据)。 Also request.ODataProperties().PathHandler
has changed to request.GetPathHandler()
.此外
request.ODataProperties().PathHandler
已更改为request.GetPathHandler()
。
在 ASP.NET Core 3.1 包 Microsoft.AspNetCore.OData 中, Request.ODataProperties()
下的大多数值现在位于Request.ODataFeature()
。
ODataProperties().Model 来自 github 上的 OData
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.