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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:29:04+00:00 2026-05-20T03:29:04+00:00

I have two classes, basically one holds Members and the other Sessions. They are

  • 0

I have two classes, basically one holds Members and the other Sessions.

They are joined together with a common field called "name". There is one member but can be many Sessions.

So if I do a standard join I get back 1 member and many sessions. I just want to get back the first row of sessions.

The session has field called SessioEndTime. So I need to order by DESC on this to pick out the first record.

This is my linq; I have returns too many. I think I need a subquery but I am a little confused.

  var sessions = from m in this.members 
                   join s in this.sessions
                   on m.Name equals s.Name
                   select new { MemberName = m.Name, SessionTime = s.SessioEndTime};

Edit

To make it clear, imagine I have five members, each member has NUMEROUS sessions. I just wish to receive my five members but with only one session each, that session is the LATEST session which can be got from the SessioEndTime.

  • 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-20T03:29:05+00:00Added an answer on May 20, 2026 at 3:29 am

    Try this:

    var sessions =  
        from m in this.members                     
        join s in 
        (
            from se in this.sessions
            group se by se.Name into g
            select new {Name = g.Key, SessioEndTime = g.Max(a=>a.SessioEndTime)}
        )   
        on m.Name equals s.Name                    
        select new { MemberName = m.Name, SessionTime = s.SessioEndTime}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes one of which inherits from the other. Im trying to
I have two tables. The first Holds a list of classes with basically an
I have two classes, one has a lot of properties and the other has
I have two classes generated by LINQ2SQL both from the same table so they
I have two classes that refer to each other, but obviously the compiler complains.
I have two classes, call them A and B. They both contain a Loader
I have two classes. They're almost identical, except for 2 attributes. I need to
I have two java classes called Reader and Worker. Reader reads strings from a
Say I have two classes One, the Foo class, interfaces with the user, and
I have two classes.... Parcel and FundParcel...and I'm trying to convert an IEnumerable of

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.