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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:21:20+00:00 2026-05-10T20:21:20+00:00

Say I have a list of all Projects , and that I group them

  • 0

Say I have a list of all Projects, and that I group them by Category like this:

var projectsByCat = from p in Projects                     group p by p.Category into g                     orderby g.Count() descending                     select new { Category = g.Key, Projects = g }; 

Now I want to display this as a list in a web page, where first I create the left side div, secondly the right side div. I am ordering by number of Projects in each Category to show the Categories with the most Projects on top – thus I would like to split projectsByCat in two – if I put all the "odd numbered" Categories on the left and the "even numbered" categories on the right, I think I will get a reasonably sane view.

So I thought I could do this to get the odd and even members of projectsByCat:

var oddCategories = projectsByCat.Where((cat, index) => index % 2 != 0);  var evenCategories = projectsByCat.Where((cat, index) => index % 2 == 0); 

And it compiles – however, when I run it, I get an exception such as this:

Unsupported overload used for query operator ‘Where’.

And I thought I was safe since it compiled in the first place.. 😉

Is there an elegant way to do this? And also, is there an elegant explanation for why my creative use of Where() won’t work?

  • 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. 2026-05-10T20:21:21+00:00Added an answer on May 10, 2026 at 8:21 pm

    If you’re using LINQ to SQL or LINQ to Entities you should first fully materialize the results into memory:

    var oddCategories  = projectsByCat.ToList().Where((c,i) => i % 2 != 0); var evenCategories = projectsByCat.ToList().Where((c,i) => i % 2 == 0); 

    It isn’t possible to iterate through results on the database with an indexer without the use of a cursor, which either ORM framework does not do.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer They come from the MainWindow.xib (or similar) file in your… May 11, 2026 at 11:27 am
  • added an answer QT has a eventFilter that 'captures' QEvent.MouseButtonRelease. So what I… May 11, 2026 at 11:26 am
  • added an answer No, and your ps is correct. Null would evaluate to… May 11, 2026 at 11:26 am

Related Questions

Say I have a list of all Projects , and that I group them
So say I have a products table with a list of products, and one
Let's say I have a list of categories for navigation on a web app.
If I have a list of items, say apples pairs pomegranites and I want
I have a list of objects (for the sake of example, let's say 5).
Lets say I have an entity Foo, and it contains a list of another
How could I unpack a tuple of unknown to, say, a list? I have
Say I have a list as follows: item1 item2 item3 Is there a CSS
Say I have a list and I want it arranged so that the sum
Let's say I have a List object and an iterator for that list. Now

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.