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

  • Home
  • SEARCH
  • 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 3428378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:57:07+00:00 2026-05-18T06:57:07+00:00

Is it possible to return 2 selects with 1 Iqueryable? I have a method

  • 0

Is it possible to return 2 selects with 1 Iqueryable?

I have a method that basically returns some records but I use it for paging so I also need to return the number of TOTAL records. It’s working, but rather than creating a concrete class with 2 properties (1 for the count and 1 for my select) I would rather stick with IQueryable but I am unsure if it is going to work.

Here’s an example what is returned from my COUNT:

 56

This refers to the amount records in the table.

And then my select returns a page with a number of records per page i.e.

ID      Name
32      John
33      Peter
34      David

so as you can see I have in effect 2 selects – 1 that returns the amount of records in the table and 1 that returns a subset of records from the table. Of course I am executing these 2 values as 2 separate queries in my method (C#) so I have 2 iqueryable vars in effect and I need to return both from the method.

So I wanted to keep my return method in line with the standard for a repository pattern i.e. returning IQueryable – but how would I do this?

I didn’t want to create 2 methods, 1 for returning the count and the other for returning the subset and as I say I didn’t want to change the return type to a concrete class (for example) that has 2 properties called Count and Data.

  • 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-05-18T06:57:08+00:00Added an answer on May 18, 2026 at 6:57 am

    No, basically. LINQ-to-SQL itself supports multiple grids, but typically when calling a stored-proc, and not via IQueryable<T>. And since you don’t want to change the schema you can’t use a cheeky ExecuteQuery<T> with a dummy column. So no.

    You could, however, do something like the following (which will of course mandate 2 round-trips to the server):

    public static IQueryable<T> GetPage(this IQueryable<T> query,
        int skip, int take, out int count)
    {
        count = query.Count();
        return query.Skip(skip).Take(take);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that selects some fields to display from a table SELECT
Possible Duplicate: return AJAX callback return I have made a JQuery code using AJAX,
The Problem I need some properties of each item that query returns as array
Input: The customer claims that the application (.NET) when querying for some data returns
I have a DataGridView with myGridView.DataSource = GetSomeData() // method called public IQueryable GetSomeData()
The query selects the oldest row from a records table that's not older than
I have MySQL query that selects user names and theirs knowledge (may be more
I have a fairly complicated linq query that returns an item and a string[]
I have the following code that builds an IQueryable Expression<Func<TParentEntity, TChildEntity, bool>> joinExpr =
I'm trying to extend a method that already has a return type. For example:

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.