How can you store the data in the list by group?
Say,
public class ProductPrice
{
public string Name { get; set }
public decimal Price { get; set; }
// Date and other properties
}
then having a record like this:
+--------+--------+
| Name | Price |
+--------+--------+
| Chair | 11 |
| Table | 15 |
| Table | 30 |
| Window | 24 |
| Chair | 29 |
+--------+--------+
What should be done in order to achieve a list something like this:
{
{
new ProductPrice { Name = "Chair", Price = 11 },
new ProductPrice { Name = "Chair", Price = 29 },
},
{
new ProductPrice { Name = "Table", Price = 15 },
new ProductPrice { Name = "Table", Price = 30 }
},
{
new ProductPrice { Name = "Window", Price = 24 }
}
}
As you can see, they are grouped by their Name
and store them in a list per group. It would be great to feed them to a, say, line chart to see their price trends. It's just that I am having hard time creating the list.
In a nutshell, can I create a List
that is grouped by Products Name? Also, products can have new record as well?
>` ???
– Habib Oct 24 '14 at 16:38