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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:01:15+00:00 2026-06-02T14:01:15+00:00

I have table Products where I store my products and another table Votes which

  • 0

I have table Products where I store my products and another table Votes which cointains user votes for that products.

Product:
ID
Name
Price
etc..

Votes:
ID
ProductID
IpAdress
DateTimeCreated

How would I get most voted products in last 24 hours in linq to sql? I’m really not that good with L2S to figure it on my own.

This is closest I got so far, this snippet should get last 10 voted, but I need top voted in last 24h:

 var last10Voted = (from vote in context.Votes join product in 
 context.Products on vote.ProductID equals
 product.ID orderby vote.DateTimeCreated select product).Take(10);
  • 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-02T14:01:28+00:00Added an answer on June 2, 2026 at 2:01 pm
    var topVotedProducts = 
        Votes.Where(v => v.DateTimeCreated > DateTime.Now.AddHours(-24))
            .GroupBy(v => v.ProductID)
            .Join(Products, g => g.Key, p => p.ID, (g,p) => new { cnt = g.Count(), prod = p.Name })
            .OrderByDescending(result => result.cnt);
    

    Product:
    ID
    Name
    Price
    etc..

    Votes:
    ID
    ProductID
    IpAdress
    DateTimeCreated

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

Sidebar

Related Questions

I have a standard store schema with an InvoiceLine table that contains Products. I'd
Hello i have a products table that contains normal products and configurable product It
Hi I have table called Sold Products which stores buying information for product &
I have a product table with 100000 products and also I have a user
I have a table that store Tags like so: ProductTags TagID PK Name nvarchar(50)
I have a MySql table called reviews which stores a lot of product reviews,
I have table 'products' and I need to update 'price' field by 20% if
I have a table called products containing a field called price and I simply
i have two tables product product_id product_Name product_Price product_Description product_image category_id another table category
Suppose I have a table view with 5 rows, each row have product name(UiLabel),

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.