In addition to my previous question, I still have no concrete solution to my problem.
I have 2 classes like this:
public class Product
{
public Product()
{
Options = new List<Option>();
}
public string Name { get; set; }
public int ID { get; set; }
public List<Option> Options { get; set; }
}
public class Option
{
public int SubID { get; set; }
public string SubName { get; set; }
public int ListBoxID { get; set; }
public decimal Price { get; set; }
public bool IsSelected { get; set; }
}
Which are used in a list like this:
List<Product> Products { get; set; }
When a user selects a product on the left (which are always with the same properties), it's internal List<Optie>
will get loaded in 4 different ListBox's
, Filtered by ListBoxID
.
Now, if a user selects the same options in 2 products, how can I convert them into one result using linq?
e.g. 4 identical products are loaded, user selects the same options for 2 products, then my result would be:
2x Product
2x lookbrood
2x ollema
2x fitness broodje
2x testtest
If the 2 other products have different selections, these might be the result for them:
2x Product
2x ciabatta broodje
2x ollema
2x slagroom
2x smos
I always need the quantity loaded into Products
:
e.g.: 6 products are loaded, then my combinations can be:
3x Product
3x ciabatta broodje
3x ollema
3x slagroom
3x smos
3x Product
3x Some other option 1
3x Some other option 2
3x Some other option 3
3x Some other option 4
or
2x Product
2x Some option 1
2x Some option 2
2x Some option 3
2x Some option 4
2x Product
2x Some other option 1
2x Some other option 2
2x Some other option 3
2x Some other option 4
2x Product
2x Some other option 1
2x Some other option 2
2x Some other option 3
2x Some other option 4
This is the best explanation I can give, I hope the image helps.