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

  • Home
  • SEARCH
  • 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 6782559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:45:23+00:00 2026-05-26T16:45:23+00:00

My object is in this form List<SignUp> class SignUp { public int Id {

  • 0

My object is in this form

List<SignUp>

class SignUp
{
  public int Id { get ; set;}
  public int VersionId { get ; set;}
  public int PersonId{ get ; set;}
  public DateTime? SignUpDate { get ; set;}
}

People signup to a version of a document. Some versions never get archived and they have to resign every year.
so I end up with records like

SignUp s = new SignUp { Id = 1, VersionId = 1, PersonId = 5}
SignUp s2 = new SignUp { Id = 2, VersionId = 2, PersonId = 5}
SignUp s3 = new SignUp { Id = 3, VersionId = 1, PersonId = 5}

No this list which has s, s2, s3 has 2 duplicates on personId, versionId combination which are s & s3. only thing is s3 has a higher Id than s.
Hence I want to eliminate s and just display s2, s3 (s is an older version and I ignore it)

How can this be achieved using a linq query if possible?

  • 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-26T16:45:24+00:00Added an answer on May 26, 2026 at 4:45 pm

    How about:

    List<SignUp> signups = ...
    
    var filteredSignups = from signup in signups
                          group signup by new { signup.PersonId, signup.VersionId }
                                          into pvIdGroup
                          select pvIdGroup.OrderBy(groupedSignUp => groupedSignUp.Id)
                                          .Last();
    

    The idea is to group the items by the two properties and then pick the “best” item from each group.

    If you don’t want the inefficiency of sorting the items within each group, consider using an O(n) MaxBy method, such as the one from morelinq.

    Then the select becomes:

    select pvIdGroup.MaxBy(groupedSignUp => groupedSignUp.Id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this object class Contact { public IEnumerable<Person> People { get; } public string
I have this object: class a { public string Application; public DateTime From, To;
When I bind this object public class MyObject { public AgeWrapper Age { get;
Getting a rendering error for this form: 'NoneType' object has no attribute 'widget' http://dpaste.com/88585/
In the constructor of my class, I map the current object ( this ),
Say you have the following object: public class Address { public String Line1 {
I have a collection named as MenuItemCollection and this derived form List< MenuItem >
Here's the problem I'm trying to cast form List to an object MyTypes which
My AJAX-enabled WCF service returns JSON using this contract, [DataContract] public class JQGridContract {
I have a form for an object called AccountImport . This form lives in

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.