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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:11:26+00:00 2026-06-17T20:11:26+00:00

I have seen grouping examples to get sum or other aggregate function outputs, but

  • 0

I have seen grouping examples to get sum or other aggregate function outputs, but i am stuck in trying to get the “record” which matches a grouped criteria, i do not need a aggregate value. Let me explain my situation:

Im using LINQ to EF, I have a table, Entity_Revisions with columns Entity_Id, Entity_Revision_Number and lots of other columns. The Entity_Revision_Number is like a version of the entity. So i want a LINQ query to give me the latest version. Below is the kind of data:

 Entity_Id Entity_Revision_Number
 1         0
 1         1
 2         0
 3         0
 3         1

I need a query that returns records 1,1 2,0 and 3,1. The query i would need is kind of

from e in ENTITY_REVISIONs
<some joins>
<some where>
group e by e.ENTITY_ID into g
select g <where max(g.entity_revision_number)>

Also is it possible to get the ENTITY_REVISIONs type as output and not in the form of new{} annonymous type?

  • 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-17T20:11:27+00:00Added an answer on June 17, 2026 at 8:11 pm

    Group by id, order each group descending by revision number, and get first value of each group should be fine :

    var query = from e in ENTITY_REVISIONs
                group e by e.ENTITY_ID into grp
                select grp.OrderByDescending(x => x.entity_revision_number).First();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen other questions on here related to this, but I have their
Have seen multiple posts on this but I can't see any which answer my
I have seen many examples where a search task was launched from application but
I have seen this talked about but never answered. Maybe it has and I'm
I have seen many question about 'JavaScript works only on alert', but the answers
Have seen that this piece of code could solve my problems but I don't
I have seen this character a number of times in CSS files but I
i have seen some code in which people pass parameter through commandParameter Property of
I have seen multiple topics about online payment processors (OPP), but none of them
Have seen some conversations revolving around this, but hoping for some current input as

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.