I have a class called "Orders" that has the property of "City" among others. I am trying to write a LINQ statement that will get all the distinct cities from a list of orders and return them as a list of strings.
Here is what I have now.
public List<string> GetOrderCities(List<Order> orders)
{
IEnumerable<string> cities= from o in orders
select o.City.Distinct().ToString();
return cities.ToList();
}
However, when I run this by passing it a list of orders, I don't seem to be getting anything back. The list is empty that it is returning. The orders I am passing it do all have City values. Am I just flat out doing this wrong? Thanks!