Afternoon all
I have a lovely webservice call that brings back a list, we'll call it List<Everything>
This would return something along the lines of:
Product ProductName SomethingElse
1 Dave abc
1 Dave def
1 Dave ghi
2 Jason abc
2 Jason def
3 Terry abc
3 Terry def
3 Terry ghi
3 Terry jkl
I then have another List<Products> (int Product, string ProductName) that I would like to populate using the distinct product information in List<Everything>.
So I'm trying to get the following result:
Product Productname
1 Dave
2 Jason
3 Terry
How can I achieve this using Linq?
Apologies for what is probably bloody obvious.
List<Products> products = (from x in everythingList
group x by new { x.Product, x.ProductName } into xg
select new Products
{
Product = xg.Key.Product,
ProductName = xg.Key.ProductName
}).ToList();
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