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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:10:23+00:00 2026-05-18T10:10:23+00:00

I am a newbie to Linq. I am trying to write a linq query

  • 0

I am a newbie to Linq. I am trying to write a linq query to get a min value from a set of records. I need to use groupby, where , select and min function in the same query but i am having issues when using group by clause. here is the query I wrote

var data =newTrips.groupby (x => x.TripPath.TripPathLink.Link.Road.Name)
                  .Where(x => x.TripPath.PathNumber == pathnum)
                  .Select(x => x.TripPath.TripPathLink.Link.Speed).Min();

I am not able to use group by and where together it keeps giving error .

My query should

  1. Select all the values.
  2. filter it through the where clause (pathnum).
  3. Groupby the road Name
  4. finally get the min value.

can some one tell me what i am doing wrong and how to achieve the desired result.

Thanks,
Pawan

  • 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-18T10:10:23+00:00Added an answer on May 18, 2026 at 10:10 am

    It’s a little tricky not knowing the relationships between the data, but I think (without trying it) that this should give you want you want — the minimum speed per road by name. Note that it will result in a collection of anonymous objects with Name and Speed properties.

    var data = newTrips.Where(x => x.TripPath.PathNumber == pathnum)
                       .Select(x => x.TripPath.TripPathLink.Link)
                       .GroupBy(x => x.Road.Name)
                       .Select(g => new { Name = g.Key, Speed = g.Min(l => l.Speed) } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
I am a LINQ newbie trying to use it to acheive the following: I
Newbie here...can I write one program which incorporates .NET LINQ and also various Java
Greetings! I want to use LINQ to query a list of objects and sort
I am newbie to LINQ. I am trying to read the following node and
Silverlight newbie here, trying to do a simple databinding: Im trying to get a
I am a Linq to SQL newbie and I noticed, when I query the
Newbie question here. I am trying to use the django-extjs library in my django
I have a newbie LINQ question. I need to create two objects of same
Newbie in the Linq to XML arena... I have a Linq query with results,

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.