0

当我使用简单的 API 时:/api/dashboard 效果很好!

但是,我添加的任何过滤器都会返回以下错误!

API URI

/api/dashboard?$filter=(ProximoAtendimento%20gt%20datetime'2012-11-30'%20and%20ProximoAtendimento%20lt%20datetime'2012-12-02')

错误

{
    "Message": "An error has occurred.",
    "ExceptionMessage": "Method not found: 'Microsoft.Data.OData.Query.SemanticAst.ParameterQueryNode Microsoft.Data.OData.Query.SemanticAst.FilterQueryNode.get_Parameter()'.",
    "ExceptionType": "System.MissingMethodException",
    "StackTrace": "   at System.Web.Http.OData.Query.Expressions.FilterBinder.BindFilterQueryNode(FilterQueryNode filterNode)\r\n   at System.Web.Http.OData.Query.Expressions.FilterBinder.Bind(FilterQueryNode filterNode, Type filterType, IEdmModel model, IAssembliesResolver assembliesResolver, ODataQuerySettings querySettings)\r\n   at System.Web.Http.OData.Query.FilterQueryOption.ApplyTo(IQueryable query, ODataQuerySettings querySettings, IAssembliesResolver assembliesResolver)\r\n   at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings)\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)"
}

API 控制器

[Queryable]
public IQueryable<Pessoa> get()
{
    return _repository.Query<Pessoa>();
}

包版本

  1. Microsoft.AspNet.WebApi.OData -> 0.2.0-alpha
  2. Microsoft.Data.Edm -> 5.1.0
  3. Microsoft.Data.OData -> 5.1.0
  4. Microsoft.Data.OData.Contrib -> 5.1.0.51119
  5. System.Spatial -> 5.1.0
  6. Microsoft.AspNet.WebApi -> 4.0.20710.0
  7. Microsoft.AspNet.WebApi.Client -> 4.1.0-alpha-120809
  8. Microsoft.AspNet.WebApi.Core -> 4.0.20710.0
  9. Microsoft.AspNet.WebApi.OData -> 0.2.0-alpha
  10. Microsoft.AspNet.WebApi.Web...-> 4.0.20710.0
4

1 回答 1

0

MissingMethodExceptions 通常是由不匹配的程序集版本引起的。在您的情况下,您似乎应该使用这个 NuGet 包:

5.1.0.51016-rc2 用于 Microsoft.Data.OData.Contrib 而不是 5.1.0.51119。

请参阅:http ://www.nuget.org/packages/microsoft.aspnet.webapi.odata

于 2012-12-02T03:18:34.150 回答