query - odata web api functions




ASP.Net MVC4 RC Web-Api Odata filter not working with IQueryable (3)

From what I see (on 9/20/12) you need the https://nuget.org/packages/Microsoft.AspNet.WebApi.OData/0.1.0-alpha-120815 Nuget package to get this to work. Unfortunately, it's still in pre-release. The [Queryable] attribute is in this package.

I haven't found very good information on this.

In ASP.net MVC4 RC's Web-api, I had a Get action defined like before:

public IQueryable<Person> Get()
    {
        var lst = ctx.GetListFromDB();
        return lst.AsQueryable();
    }

When it was I was running it before if I called a url like: /api/people?$inlinecount=allpages&$format=json&$top=50&$filter=(State+eq+'AL'+and+Zip+eq+'35242')

It would do the filtering on the objects, has something changed since the beta that would break this?



How can I return IQueyrable DTO from Webapi Get so I can use Odata filters

It does work in RC but perhaps not in RTM when it ships - not quite clear yet.

Your problem is that you are disposing your context since you are using a using block. So context get disposed before the data is retrieved.

So instead of using register your object for disposal at the end of request. Tugberk has a post here.