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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:38:55+00:00 2026-06-08T15:38:55+00:00

First Table +——–+————+——-+ | type | variety | price | +——–+————+——-+ | apple |

  • 0
First Table
+--------+------------+-------+
| type   | variety    | price |
+--------+------------+-------+
| apple  | gala       |  2.79 | 
| apple  | fuji       |  0.24 | 
| apple  | limbertwig |  2.87 | 
| orange | valencia   |  3.59 | 
| orange | navel      |  9.36 | 
| pear   | bradford   |  6.05 | 
| pear   | bartlett   |  2.14 | 
| cherry | bing       |  2.55 | 
| cherry | chelan     |  6.33 | 
+--------+------------+-------+
Second Table
+--------+----------+
| type   | minprice |
+--------+----------+
| apple  |     0.24 | 
| cherry |     2.55 | 
| orange |     3.59 | 
| pear   |     2.14 | 
+--------+----------+
select type, min(price) as minprice
from fruits
group by type;

The first table is and example of the data that I have and the second table is what I want to get from the first.

I am using GenericRepository/UnitOfwork to get the data from repository.

repository.fruitRepository.Get().GroupBy(m => m.type);

But I can only get the type field but I want to get more fields.

Do I need to use a select clause before groupby? If yes, how can I select more fields?

  • 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-08T15:38:56+00:00Added an answer on June 8, 2026 at 3:38 pm

    The GroupBy method returns more data, but it’s returned as an enumerable… you may be able to pull what you want out of it with a Select after the GroupBy…

    repository.fruitRepository.Get()
        .GroupBy(m => m.type)
        .Select(m => new { type = m.Key, minPrice = m.Min(f => f.Price) });
    

    Or if you prefer a LINQ statement:

    var result = from x in repository.fruitRepository.Get()
                 group x by x.type into typeGroup
                 select new
                 {
                     type = typeGroup.Key,
                     minPrice = typeGroup.Min(item => item.Price)
                 };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables. First table have columns: price, code_one Second table has: code_one,
First Table is the View and Second is the result I want This below
I have a first table view and a segue that pushes to another table
I was looking at the first table on http://zero.milosz.ca/ , and wanted to understand
i have 3 Tables is my SQL Database: First Table: Room: ID <pk>, Roomname
I've got two tables with similar structure: - First table: id and col1,col2,col3 -
I have a DataSet , where in the first table and in the row
I have two tables. The first table has a column with a lot of
I've got 2 tables. The first table is full of entries. The second table
I have 2 tables, let says the first table named Schedule and the second

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.