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 8424573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:01:52+00:00 2026-06-10T04:01:52+00:00

Possible Duplicate: OData pagination with WebApi ( $inlinecount ) Since Asp.net WebAPi almost supports

  • 0

Possible Duplicate:
OData pagination with WebApi ( $inlinecount )

Since Asp.net WebAPi almost supports odata, its very enticing for me to get $inlinecount to work so that it plays nicely with kendo ui ( or any other).
So that it returns value in jsonp format, i implemented a new MediaFormatter ( from Stackoverflow).

Trouble is that it needs the results to have count element in them in order to get server side paging to work, so for now i hacked the formatter to get a fake count to work. This all works great and the grid is all happy, however getting the real count is a challenge since IQueryable expression being returned already has filters/Take etc applied to it.

 public override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContentHeaders contentHeaders, TransportContext transportContext)
    {
        string callback;
        if (IsJsonpCountableRequest(out callback))
        {
            return Task.Factory.StartNew(() =>
            {
                var q = value as IQueryable<Movie>;
                var count = q.Count(); // this count doesnt return the actual count
                var writer = new StreamWriter(stream);
                writer.Write(callback + "({");
                writer.Write(@"""d""");
                writer.Write(" : { ");
                writer.Write(@"""results""");
                writer.Write(" : ");
                writer.Flush();
                base.WriteToStreamAsync(type, value, stream, contentHeaders, transportContext).Wait();
                writer.Write(",");
                writer.Write(@"""__count""");
                writer.Write(" : ");

                writer.Write(string.Format(@"""{0}""", count));
                writer.Write("}");

                writer.Write("})");
                writer.Flush();
            });
        }
        else
        {
            return base.WriteToStreamAsync(type, value, stream, contentHeaders, transportContext);
        }
    }

Is there a way to get the a count separately, may be from the underlying provider of the IQueryable ?

  • 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-10T04:01:53+00:00Added an answer on June 10, 2026 at 4:01 am

    Try this approach: http://www.strathweb.com/2012/08/supporting-odata-inlinecount-with-the-new-web-api-odata-preview-package/

    It uses the latest Web API OData package.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: std::string and its automatic memory resizing I am just curious, how are
Possible Duplicate: Unable to get a list of installed Python modules How do I
Possible Duplicate: Javascript window resize event I want to get an event which is
Possible Duplicate: Why do I get a null pointer exception from TabWidget? I have
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: Trying to get tables next to each other horizontal I have two
Possible Duplicate: How can I get device ID for Admob My activity has a
Possible Duplicate: How to store an IP in mySQL I want to get the

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.