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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:21:32+00:00 2026-06-09T16:21:32+00:00

I have this list var commonContractsList = ( from i in referredDilutions join f

  • 0

I have this list

var commonContractsList = (
        from i in referredDilutions
        join f in dilutionsList
            on i.Contract equals f.Contract
        select f)
    .ToList();

The list commonContractsList has several fields and three in particular, contract, instalment and amount. We can have several instalments for one contract. Every contract/instalment has an amount.

Now, what I want to do is get, for each contract, a list of all records of contracts where the instalment has the higher amount.

Source Data

contract    instalment    amount
1           1             100
1           2             1000
2           1             100
3           1             1000
4           1             200
4           2             100
5           1             1000

So i need,

Results

contract    instalment    amount
1           2             1000
2           1             100
3           1             1000
4           1             200
5           1             1000 

My knowledge of linq is limited and I’m having a hard time with project.

Any ideas?

  • 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-09T16:21:33+00:00Added an answer on June 9, 2026 at 4:21 pm

    The following code should give you the expected results:

    var data = new[]
    {
        new { contract = 1, installment =  1, amount = 100},
        new { contract = 1, installment =  2, amount = 1000},
        new { contract = 2, installment =  1, amount = 100},
        new { contract = 3, installment =  1, amount = 1000},
        new { contract = 4, installment =  1, amount = 200},
        new { contract = 4, installment =  2, amount = 100},
        new { contract = 5, installment =  1, amount = 1000},
    };
    
    var result = from d in data
                 group d by d.contract into g
                 let highestInstallment = (from x in g
                                           orderby x.amount descending
                                           select x).First()
                 select new
                 {
                     contract = g.Key,
                     installment = highestInstallment.installment,
                     amount = highestInstallment.amount
                 };   
    

    You group by contract and then within each group you check for the highest amount. I’ve added the let clause so you don’t have to repeat the sub query for both installment and amount.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this e.g. code: var list = (from item in db.Table select item).ToList();
So I have this Query: var list = (from x in xList join a
I have this query: var list = (from t1 in context1.SomeTable join t2 in
I have this command (visibleSelect is jquery variable that holds multiple select list): var
i have this code: var list = new List<int>(); for(int i=0;i<10;i++) list.Add(i); for(int i=0;i<10;i++)
I have an ordered list like this: var list = new List<String>(){aaa,aab,aac,baa,bab,bac}; I want
I have a var that contains a big list of words (millions) in this
I have a nested oredered list which i m animating using this code... var
I have some LINQ code that generates a list of strings, like this: var
I have this object in JS: var list = {134 : A,140 : B,131

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.