Consider the following object:
public class Address { public string city; public string state; public string country; }
If I have a list of addresses how would I use LINQ to get a list of counts where the city, state, and country match.
So my result might look something like this:
Thanks!
Went one step further than Marc's answer (which he edited before I posted!). LOL
var qry = from addr in addresses
          group addr by new { addr.city, addr.state, addr.country } into grp
          select new
          {
            city = grp.Key.city,
            state = grp.Key.state,
            country = grp.Key.country,
            count = grp.Count(),
          };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With