EDIT: I read this answer, and was curious if I can do something similar.
My project have a data layer which communicate with the database only by stored procedures. One of the procedures returns data from two tables, which has one to many relationship. I'm using the OracleDataAdapter from Oracle Data Access library. The Adapter fills a DataTable. I have a entity class A that has a List of another entity class B. I need to convert the DataTable to match this relationship. The Datatable will be filled with multiple rows that has only different B objects. Is there a way I can accomplish this?
EDIT2: Let's say I have 2 classes, A and B.
public class A{
public int Id { get; set; }
public string Nome { get; set; }
public string Descricao { get; set; }
public DateTime Data { get; set; }
public int Quantidade { get; set; }
public List<B> Bs { get; set; }
}
public class B{
public int Id { get; set; }
public string Nome { get; set; }
}
And I have a DataTable with data like:
Id Nome Descricao Data Quantidade Id_B Nome_B
1 "nome1" "desc1" 05/07/2013 2 5 "nomeB_1"
1 "nome1" "desc1" 05/07/2013 2 13 "nomeB_2"
So, A can have multiple B objects. I want to make a generic parser, that can take this DataTable and convert it to a List of B within a List of A. I think its possible to use Marc Gravell's solution with some recursive method that analises the property for know if is a List, and process it for each duplicated Id in A. Anyone know if this is possible?
Thank you in advance, and I apologize for the bad english.