You will need to iterate through each DataTable result and group the information of each Order into a dictionary indexed by your Id, so that you can aggregate the OrderDetails in the same Order instances.
The first step is to make the details list public:
public class Order
{
//Precisa ser público, já que a modelagem sugere que um Order
//pode ter mais de um OrderDetails. Precisaremos adicionar
//mais detalhes ao iterar nas linhas do DataSet.
public List<OrderDetails> Details { get; set; }
//Mantive o OrderDetail sendo passado no construtor, já que o
//modelo explicita que um Order deve possuir ao menos um OrderDetail
public Order(OrderDetails detail)
{
this.Details = new List<OrderDetails>();
this.Details.Add(detail);
}
}
Now we can iterate through the DataSet results and populate the class.
I will assume some premises:
1) that the Order Id is a String. This premise is based only on the fact that it is easier to deal with String in the example. Make the necessary conversions for your code.
2) that your Dataset has already been configured and a DataTable has already been created from it. If this premise is false, please search first on how to access DB data via DataSet:
private IEnumerable<Order> GetOrdersFromDataTable(DataTable ordersTable)
{
var orderDict = new Dictionary<string, Order>();
foreach (DataRow dr in ordersTable.Rows)
{
var orderDetail = new OrderDetail();
//Todo: Preencher as propriedades do OrderDetail.
string id = dr["Id"].ToString());
if (!orderDict.ContainsKey(id))
{
var order = new Order(orderDetail);
//Todo: Preencher as propriedades do Order.
orderDict.Add(id, order);
}
else
orderDict[id].Details.Add(orderDetail);
}
return orderDict.Values;
}
You asked if it was possible to populate classes with linq, but I believe you meant Linq2Sql, which is a tool for abstracting access to the data source, mapping tables into classes, and allowing queries using linq. There is another library, however, called Entity Framework, more robust than the previous one, which came to replace it. If you are interested in learning more, I suggest you research EF and try to implement an access to your bank using it. The documentation is extensive and there is also material in Portuguese. If you have any questions, please ask another question in StackOverflow so that it does not become too large.