Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9279855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:43:57+00:00 2026-06-18T17:43:57+00:00

I have an ASP.NET Web API project, and I want to use oData filters

  • 0

I have an ASP.NET Web API project, and I want to use oData filters in the project, with the ASP.NET oData preview package. This means I need to use IQueryable as the response type.

Unfortunately, the consumer requires the response wrapped like so:

{
   "total": 2,
   "success": true,
   "data": [ 
           { object1 },
           { object2 } ]
}

I created a wrapper object which assigns the IQueryable response from my original version to the “data” property, and sets the values for the “total” and “success” properties as well. This creates the JSON response the consumer is looking for. But it’s no longer IQueryable, which means I can’t implement oData filters.

I was hoping to take my wrapper object and make it implement IQueryable by setting its enumerators, etc. However, I don’t think this will work because I have to assign the Provider and Expression properties to implement the interface, and I don’t know what I should put there. I’m using a Repository pattern with IoC, and the EntityFramework Code First data access is in a separate project, with concrete objects assigned to the interface placeholders using Ninject. Perhaps I can abstract out the interfaces all the way from the data access layer so that the the Repository objects carry a reference to an IQueryProvider. Do you think this would work, and allow it to support the automated oData integration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:43:58+00:00Added an answer on June 18, 2026 at 5:43 pm

    Here’s how you do it. Behind the scenes, [Queryable] just creates an instance of ODataQueryOptions and then applies it to the queryable you return. The good news is that you can parameter bind ODataQueryOptions and have code that looks like this:

    public Wrapper<MyObject> Get(ODataQueryOptions<MyObject> queryOptions)
    {
        IQueryable<MyObject> queryResults = queryOptions.ApplyTo(dbSet);
        return Wrap(queryResults);
    }
    

    You don’t even need [Queryable] anymore because you’re doing what it would have done for you. Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I handle versioning in my ASP.NET Web-Api project? I need to have
I have an ASP.NET Web API (version 4) REST service where I need to
We have an ASP.NET Web API app which uses Ninject for DI. This works
I have an ASP MVC Web Api project that outputs json using json.net. I
I have an ASP.NET Web API project. I'm trying to pass some query options
All, I have a ASP.NET Web API project that is making a REST call
The project is an Asp.Net Web API web service. I have a type hierarchy
Is it possible to use Web Api in an existing project of Asp.Net MVC
I configured an ASP.NET MVC 4 Web API project to use StructureMap 2.6.2.0 as
I have an ASP.NET Web API project that is bound to a TFS source

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.