Для предотвращения дублирования продукта используйте EqualityComparer:
public class ProductCountryEqualityComparer : IEqualityComparer<Product>
{
#region IEqualityComparer<Product> Members
public bool Equals(Product x, Product y)
{
return x != null && y != null && x.Country == y.Country;
}
public int GetHashCode(Product obj)
{
return 0;
}
#endregion
}
Тогда:
//That will make products distincts according to there Country
productList = productList.Distinct(new ProductCountryEqualityComparer()).ToList();
Для форматирования страны:
productList = productList.Distinct(new ProductCountryEqualityComparer())
.Select(f => new Product()
{
Country = string.Format(f.Country,"SomeFormat")
}).ToList();
На заказ:
productList = productList.Distinct(new ProductCountryEqualityComparer())
.Select(f => new Product()
{
Country = string.Format(f.Country,"SomeFormat")
}).OrderBy(f => f.Country).ToList();
Просто используйте последний:)