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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:27:08+00:00 2026-06-13T05:27:08+00:00

Here’s my database schema: create table Post ( PostId int primary key identity, ImageUrl

  • 0

Here’s my database schema:

create table Post
(
    PostId int primary key identity,
    ImageUrl nvarchar(1024) not null,
    [Description] nvarchar(256) not null,
    UserId int foreign key references [User](UserId),
    DateOfPost datetime not null,
    Score int
)

create table Vote
(
    VoteId int primary key identity,
    UserId int foreign key references [User](UserId),
    PostId int foreign key references Post(PostId),
    VoteDirection bit not null,
    DateOfVote datetime not null
)

Basically, I want to order the Posts by [VoteDirection == true] - [VoteDirection == false]. So it 20 people votes “true”, and 5 vote “false”, the temporary score used for ordering would be 15.

Is there also a way to select a range of date using the DateOfVote parameter?

Here’s what I’ve tried:

    // www.foo.com/top/today
    public ActionResult Today()
    {
        var posts = postRepository.FindAllPosts().Where(x => x.DateOfPost == DateTime.Today)
                                                 .OrderByDescending(x => x.Votes.Where(c => c.VoteDirection == true) - x.Votes.Where(c => c.VoteDirection == false));
        return View(posts);
    }

I’m getting the error:

Error 2 Operator ‘-‘ cannot be applied to operands of type
‘System.Collections.Generic.IEnumerable’
and
‘System.Collections.Generic.IEnumerable’

Which is understandable, they’re both collections not actual integers. But it should illustrate what I’m trying to do. Any suggestions?

  • 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-13T05:27:09+00:00Added an answer on June 13, 2026 at 5:27 am

    Just use Count:

    .OrderByDescending(x => 
        x.Votes.Count(c => c.VoteDirection) - x.Votes.Count(c => !c.VoteDirection));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my problem : I have a post controller with the action create.
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is what I am currently doing. PHP echo's out the recent post in
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),
Here's what my table TheTable looks like ColA | ColB | ColC ------+-------+------ abc
Here is a code snippet I was working with: int *a; int p =
Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change
Here's my procedure: DROP PROCEDURE IF EXISTS `couponExpires`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `couponExpires`(IN couponID BIGINT,

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.