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)"}
我失蹤了嗎?
感謝您的回答,它解決了問題! – 2013-02-13 23:32:35