I have a list of attribute values that look like this:
public class AttributeOption
{
public Guid Id { get; set; }
public string Name { get; set; }
}
public class MyAttribute
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<AttributeOption> Options { get; set; } = new List<AttributeOption>();
}
I have a list of attributes i.e. var attributes = new List<MyAttribute>();
and the list contains three sets of attributes e.g. color, size and gender. Each attribute has its options. For example, color has red, white and blue options. Size has small, medium and large and finally gender has male and female.
How do I generate a cartesian product of all these attributes? I should end up with:
Red-Small-Male
Red-Small-Female
Red-Medium-Male
...
White-Small-Male
White-Small-Female
...