当我使用简单的API时:/api/dashboard
它完美无缺!
但是,我添加的任何过滤器都会返回以下错误!
/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>();
}
套件版本
答案 0 :(得分:0)
MissingMethodExceptions通常是由不匹配的程序集版本引起的。在您的情况下,看起来您应该使用此NuGet包:
5.1.0.51016-rc2 for Microsoft.Data.OData.Contrib而不是5.1.0.51119。
请参阅:http://www.nuget.org/packages/microsoft.aspnet.webapi.odata