My list is structured like this:
public class Custo{
public int id { get; set; }
public int idParent { get; set; }
public decimal amount{ get; set; }
public decimal unitaryValue{ get; set; }
}
List<Custo> myLIst = new List<Custo>();
I want my list to return like this:
Name Total Amount Total Value
Projetos 17,00 $70
Arquitetura 15,00 $60
Estrutura 10,00 $35
Modulo 5,00 $25
Desenho 2,00 $10
Artistico 2,00 $10
Projetos Eletricos 0,00 $0
Essentially in a composite pattern you would need three classes. One would be the treenode and the other two would inherit from that. One would be a project capable of holding children. The other would be a child/leaf node and would be the individual Custos.
When you use the classes you would create a new Projectos and add child nodes, then call the Display method when you wanted them to display. You could obviously add logic for other functions. This is similar to code found here: http://www.dofactory.com/net/composite-design-pattern
Usage might be Main
Projectos
Custos
CustosNode