当我使用简单的 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>();
}
包版本
- Microsoft.AspNet.WebApi.OData -> 0.2.0-alpha
- Microsoft.Data.Edm -> 5.1.0
- Microsoft.Data.OData -> 5.1.0
- Microsoft.Data.OData.Contrib -> 5.1.0.51119
- System.Spatial -> 5.1.0
- Microsoft.AspNet.WebApi -> 4.0.20710.0
- Microsoft.AspNet.WebApi.Client -> 4.1.0-alpha-120809
- Microsoft.AspNet.WebApi.Core -> 4.0.20710.0
- Microsoft.AspNet.WebApi.OData -> 0.2.0-alpha
- Microsoft.AspNet.WebApi.Web...-> 4.0.20710.0