2013-02-13 116 views
0

我正在創建一個使用MVC 4的WebApi應用程序,它需要支持oData。找不到方法:'Int32 Microsoft.Data.OData.Query.SemanticAst.QueryNode.get_Kind()'

我按照建議安裝了包Microsoft.AspNet.WebApi.OData(Install-Package Microsoft.AspNet.WebApi.OData -Pre),但是在過濾時[例如:/ api/cars?$ filter = startswith(Name, 'F')]我得到的例外:

{"Message":"An error has occurred.","ExceptionMessage":"Method not found: 'Int32 Microsoft.Data.OData.Query.SemanticAst.QueryNode.get_Kind()'.","ExceptionType":"System.MissingMethodException","StackTrace":" at System.Web.Http.OData.Query.Validators.FilterQueryValidator.ValidateSingleValueNode(SingleValueNode node, ODataValidationSettings settings)\r\n at System.Web.Http.OData.Query.Validators.FilterQueryValidator.ValidateQueryNode(QueryNode node, ODataValidationSettings settings)\r\n at System.Web.Http.OData.Query.Validators.FilterQueryValidator.Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)\r\n at System.Web.Http.OData.Query.FilterQueryOption.Validate(ODataValidationSettings validationSettings)\r\n at System.Web.Http.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\r\n at System.Web.Http.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings)\r\n at System.Web.Http.QueryableAttribute.ValidateQuery(HttpRequestMessage request, ODataQueryOptions queryOptions)\r\n at System.Web.Http.QueryableAttribute.ExecuteQuery(IEnumerable query, HttpRequestMessage request, HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)\r\n at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass41`2.<Then>b__40(Task`1 t)\r\n at System.Threading.Tasks.TaskHelpersExtensions.ThenImpl[TTask,TOuterResult](TTask task, Func`2 continuation, CancellationToken cancellationToken, Boolean runSynchronously)"} 

我失蹤了嗎?

回答

1

存在與導致此問題的基礎OData庫版本的二進制不兼容問題。我強烈建議使用我們的每晚構建。就在你的,而不是包管理器控制檯使用這個命令:

Install-Package Microsoft.AspNet.WebApi.OData -Source http://www.myget.org/F/aspnetwebstacknightly/ -Pre 

這也將讓你一個版本的Web API的OData的支持這是更接近最終版本的位。

+0

感謝您的回答,它解決了問題! – 2013-02-13 23:32:35

相關問題