Entity framework 在带有实体框架的Web API上的JSON调用中使用筛选器语句

Entity framework 在带有实体框架的Web API上的JSON调用中使用筛选器语句,entity-framework,asp.net-web-api,Entity Framework,Asp.net Web Api,我们得到了一个带有实体框架的WebAPI Web服务,并接受JSON调用 我们有一个名为:GetResidents的调用,它列出了所有居民。我们希望有一个额外的参数(hash),它允许调用者在服务器上过滤结果 像这样: {"filter":{ "and":{ "age":{ "less_than":80, "greater_than":60 } }, {

我们得到了一个带有实体框架的WebAPI Web服务,并接受JSON调用

我们有一个名为:GetResidents的调用,它列出了所有居民。我们希望有一个额外的参数(hash),它允许调用者在服务器上过滤结果

像这样:

{"filter":{
      "and":{
         "age":{
            "less_than":80,
            "greater_than":60
            }
         },
         {
           "active":{
           "eq":true
           }
         }
在过去的RoR中,我使用了这个非常有效的gem:WebAPI中是否存在类似的东西


感谢您的反馈。

使用OData。这里是文档。基本示例:

public class ResidentsController : ApiController
{
    [Queryable]
    public IQueryable<Resident> GetResidents() {}
}
http://localhost/api/residents?$filter=age lt 80 and age gt 60 and active eq true