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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:09:11+00:00 2026-05-22T22:09:11+00:00

I want to group the below query by GetSetDomainName and select the row which

  • 0

I want to group the below query by GetSetDomainName and select the row which has the maximum GetSetKalanGun.In other words, I am trying to get the row with the maximum KALANGUN among those which have the same DOMAINNAME.

var kayitlar3 = (
    from rows in islemDetayKayitListesi
    select new
    {
        KAYITNO = rows.GetSetKayitNo,
        HESAPADI = rows.GetSetHesapAdi,
        URUNNO = rows.GetSetUrunNo,
        URUNADI = rows.GetSetUrunAdi,
        URUNMIKTAR = rows.GetSetUrunMiktar,

        ISLEMTARIHI = rows.GetSetIslemTarihi,
        HIZMETDURUMU = rows.GetSetHizmetDurumu,
        TOPLAMTUTAR = rows.GetSetToplamTutar,

        HIZMETBASLANGICTARIHI = rows.GetSetHizmetBaslangicTarihi,
        HIZMETBITISTARIHI = rows.GetSetHizmetBitisTarihi,
        KALANGUN = rows.GetSetKalanGun 
        DOMAINNAME = rows.GetSetDomainName,
        SIPARISDURUMU = rows.GetSetSiparisDurumu
    }).AsQueryable();

This is what I get

KAYITNO DOMAINNAME KALANGUN
1       asdf.com      30
2       domnam.com    172
3       asdf.com      40
4       xyz.com       350

This is what I want

KAYITNO DOMAINNAME KALANGUN
 2       domnam.com    172
 3       asdf.com      40
 4       xyz.com       350

var islemDetayKayitListesi = new List<IslemDetayKayit>();

islemDetayKayitListesi get filled with a foreach loop, with no problem

And that is what IslemDetayKayit looks like

public class IslemDetayKayit
{
    public int GetSetKayitNo { get; set; }
    public string GetSetHesapAdi { get; set; }
    public string GetSetUrunNo { get; set; }
    public string GetSetUrunAdi { get; set; }
    public double GetSetUrunMiktar { get; set; }
    public string GetSetIslemTarihi { get; set; }
    public string GetSetHizmetDurumu { get; set; }
    public string GetSetToplamTutar { get; set; }
    public string GetSetHizmetBaslangicTarihi { get; set; }
    public string GetSetHizmetBitisTarihi { get; set; }
    public int GetSetKalanGun { get; set; }
    public string GetSetSiparisDurumu { get; set; }
    public string GetSetDomainName { get; set; }
}

EDIT : I figured out that there was some other problem in my code, and corrected it.After that all the answer I had to this question works.Thank you for helping and teaching me new things.

  • 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-22T22:09:12+00:00Added an answer on May 22, 2026 at 10:09 pm

    You could use:

    var kayitlar3 = 
        islemDetayKayitListesi.
        Select(rows => 
        new
        {
            KAYITNO = rows.GetSetKayitNo,
            HESAPADI = rows.GetSetHesapAdi,
            URUNNO = rows.GetSetUrunNo,
            URUNADI = rows.GetSetUrunAdi,
            URUNMIKTAR = rows.GetSetUrunMiktar,
    
            ISLEMTARIHI = rows.GetSetIslemTarihi,
            HIZMETDURUMU = rows.GetSetHizmetDurumu,
            TOPLAMTUTAR = rows.GetSetToplamTutar,
    
            HIZMETBASLANGICTARIHI = rows.GetSetHizmetBaslangicTarihi,
            HIZMETBITISTARIHI = rows.GetSetHizmetBitisTarihi,
            KALANGUN = rows.GetSetKalanGun,
            DOMAINNAME = rows.GetSetDomainName,
            SIPARISDURUMU = rows.GetSetSiparisDurumu
        }).
        GroupBy(a => 
            //To ignore case and trailing/leading whitespace
            a.DOMAINNAME.ToUpper().Trim()).
        Select(g => 
             g.OrderByDescending(a => a.KALANGUN).FirstOrDefault()).
        AsQueryable();
    

    EDIT:

    So using this code:

            List<Thing> islemDetayKayitListesi = new List<Thing>();
            Thing a = new Thing() { GetSetDomainName = "abc.com", GetSetKayitNo = 1,
                GetSetKalanGun = 40 };
            Thing b = new Thing() { GetSetDomainName = "abc.com", GetSetKayitNo = 2, 
                GetSetKalanGun = 300 };
            Thing c = new Thing() { GetSetDomainName = "xyz.com", GetSetKayitNo = 3, 
                GetSetKalanGun = 400 };
            Thing d = new Thing() { GetSetDomainName = "123.com", GetSetKayitNo = 4, 
                GetSetKalanGun = 124 };
            islemDetayKayitListesi.Add(a);
            islemDetayKayitListesi.Add(b);
            islemDetayKayitListesi.Add(c);
            islemDetayKayitListesi.Add(d);
            var kayitlar3 =
                islemDetayKayitListesi.
                    Select(rows =>
                    new
                    {
                        KAYITNO = rows.GetSetKayitNo,
                        HESAPADI = rows.GetSetHesapAdi,
                        URUNNO = rows.GetSetUrunNo,
                        URUNADI = rows.GetSetUrunAdi,
                        URUNMIKTAR = rows.GetSetUrunMiktar,
    
                        ISLEMTARIHI = rows.GetSetIslemTarihi,
                        HIZMETDURUMU = rows.GetSetHizmetDurumu,
                        TOPLAMTUTAR = rows.GetSetToplamTutar,
    
                        HIZMETBASLANGICTARIHI = rows.GetSetHizmetBaslangicTarihi,
                        HIZMETBITISTARIHI = rows.GetSetHizmetBitisTarihi,
                        KALANGUN = rows.GetSetKalanGun,
                        DOMAINNAME = rows.GetSetDomainName,
                        SIPARISDURUMU = rows.GetSetSiparisDurumu
                    }).
                    GroupBy(anon =>
                        anon.DOMAINNAME).
                    Select(g =>
                        g.OrderByDescending(anon => anon.KALANGUN).First()).
                    AsQueryable();
            kayitlar3.ToList().
                ForEach(anon => Console.WriteLine("{0}, {1}, {2}", 
                    anon.KAYITNO, anon.DOMAINNAME, anon.KALANGUN));
    
        struct Thing 
        {
            public int GetSetKayitNo { get; set; }
            public int GetSetHesapAdi { get; set; }
            public int GetSetUrunNo { get; set; }
            public int GetSetUrunAdi { get; set; }
            public int GetSetUrunMiktar { get; set; }
    
            public int GetSetIslemTarihi { get; set; }
            public int GetSetHizmetDurumu { get; set; }
            public int GetSetToplamTutar { get; set; }
    
            public int GetSetHizmetBaslangicTarihi { get; set; }
            public int GetSetHizmetBitisTarihi { get; set; }
            public int GetSetKalanGun { get; set; }
            public string GetSetDomainName { get; set; }
            public int GetSetSiparisDurumu { get; set; }
        }
    

    I get the expected output:

    2, abc.com, 300
    3, xyz.com, 400
    4, 123.com, 124
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want an equivalent linq to object query for the below sql query SELECT
I want to know which of the 2 queries below is faster :- Select
I want to group results of query by the item id and count number
I am trying to create a conversations based messaging system. I want to group
I have some data that has various attributes and I want to hierarchically group
I have a table like below. I want to be able to get a
I'm having to use MS Access to query local tables. I want to group
I'm trying the query below and MySQL gave me this error: Invalid use of
In my query below, i am trying to join one result set to another
I have the sql query below. I want to take the results and insert

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.