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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:44:33+00:00 2026-05-27T22:44:33+00:00

I have two tables POSTS and COMMENTS. One post can have many comments and

  • 0

I have two tables “POSTS” and “COMMENTS”. One post can have many comments and I want to be able to select the top 10 posts with highest number of comments. The post_id is a FK in the comments table. I am using Linq to SQL. Please advise me on how to do this . Thanks in advance.

EDIT

var top = (from q in db.question_tables
                   from a in db.answer_tables
                   where q.QUEST_ID.Equals(a.ANS_QUEST_ID)
                   orderby q.QUEST_TEXT.Count() descending
                   select new
                   {
                       QUEST_TEXT = q.QUEST_TEXT


                   }).Take(10);

this is how my linq query looks like now , its giving an error “Sequence operators not supported for type ‘System.String’. ” . :/

  • 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-27T22:44:34+00:00Added an answer on May 27, 2026 at 10:44 pm

    That error message is because you are calling .Count() on a string property (QUEST_TEXT). That compiles because strings are enumerable. However, Linq-to-SQL doesn’t understand this.

    If you have the relationship between the two tables mapped in your DBML file, then you can use it in your expression:

    var top = (from q in db.question_tables
               orderby q.answers.Count() descending
               select q).Take(10);
    

    However the code you posted doesn’t quite match the description you gave. You mention comments, but the code talks about answers.

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

Sidebar

Related Questions

I have two tables Posts and comments Post Table Post_id Post_content Comments table comment_id
I have two tables. One table contains comments on posts, another contains commenter information
Suppose we have two tables. Post and Comment. Post has many Comments. Pretend they
I have two tables called 'events' and 'topics' each table can have many comments.
I have two tables - forum_topics and topics_posts . I want to select rows
I have two tables posts and comments . Table comments have post_id attribute. I
I have two MySQL (MyISAM) tables: Posts: PostID(primary key), post_text, post_date, etc. Comments: CommentID(primary
I have two models, one called Notes and one called Comments. Comments can be
Let's say we have two tables here , posts and comments, the relations is
I have two tables called 'posts' and 'friends'. I want to display the my

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.