I have a dataset data representing items in a sql db:
I can have several rows for an item as I can have several suppliers able to provide it to me.
I'm getting these data and convert it to a list of objects:
public class ItemBySupplier
{
public string Item { get; set; }
public string Supplier { get; set; }
}
So I have a list of this items in a variable :
List<ItemBySupplier> itemBySuppliers
I would like to iterate over this list to get all distinct combinations possible.
Where each combination should contains a distinct list of ALL items.
I know that I will have 4 combinations possible as only two items can be found in two different suppliers:
I'm expecting to outputs the same a list of the same objects (ItemBySupplier).
The desired output would be:
- item1-supplierA / item2-supplierB / item3-supplierD / item4-supplierE
- item1-supplierA / item2-supplierC / item3-supplierD / item4-supplierE
- item1-supplierA / item2-supplierB / item3-supplierD / item4-supplierF
- item1-supplierA / item2-supplierC / item3-supplierD / item4-supplierF
Any help would be much appreciate.