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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:29:23+00:00 2026-06-10T19:29:23+00:00

This query returns the top 25 best sellers from our database, by customer: var

  • 0

This query returns the top 25 best sellers from our database, by customer:

var query =  from bs in db.MYDATABASE
             where bs.COMPANY == "MY COMPANY"
             group bs by bs.PRODCODE into g
             orderby g.Sum(x => x.MQTY) descending
             select new BestSeller
             {
                 product_code = g.Key,
                 product_description = g.First().DESCRIPTION,
                 total_quantity = g.Sum(x => x.MQTY) 
             };
var top25 = query.Take(25);

I’ve been told in this question that I need to create a projection for the following LINQ query at the following line:

total_quantity = g.Sum(x => x.MQTY)

Please could someone explain what is meant by a projection and examples of such?

  • 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-10T19:29:25+00:00Added an answer on June 10, 2026 at 7:29 pm

    Projection is the term used with respect to LINQ when you are selecting few fields from the query and creating / projecting it to a new type. When you are doing select new in your query, you are actually doing projection. In your case you are selecting fields like g.Key and g.First().DESCRIPTION from your query expression and creating a new object of type BestSeller.

    Since your original question didn’t has the total_quantity field assigned to anything that is why Jon Skeet asked you to add the sum to your projection.

    You need to see the following articles on MSDN about projection:

    Formulate Projections
    Query Expression Syntax Examples: Projection

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

Sidebar

Related Questions

Can anyone explain why this query returns an empty result. SELECT * FROM (`bookmarks`)
I have a LINQ query that returns some object like this... var query =
I have a SQL query that current returns the top 50 rows from a
I have the following query: SELECT TOP 25 CLIENT_ID_MD5, COUNT(CLIENT_ID_MD5) TOTAL FROM dbo.amazonlogs GROUP
I'm gettintg crazy with the result of this query This query returns 29.970 rows
I have this query that returns the results by ordering it by focus.name ASC.
I have this query which returns a result set with Date(column) as nvarchar datatype.
Mysql query returns result like this collector amount name 1 0.00 gihan 1 2000.00
I have this query that returns the correct data, but I would like to
I'm starting with this query: SELECT TOP 1 Parties.FirstName + ' ' + Parties.MiddleName

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.