0
Hello, I am working with c# and I have the following situation:
- I have 2 classes in the system,
Order
andProductSold
; Order
contains as property aList<ProductSold>
;- In certain Viewmodel, I have to get a list of
ProductSold
that are within aList<Order>
;
The classes are as follows...
public class ProductSold
{
...
}
public class Order
{
public List<ProductSold> ProductSolds { get; set; }
}
public class ViewModel
{
public void getProductSolds(List<Order> orders)
{
return orders.Select(x => x.ProductSolds).toList(); // ???
}
}
In doing so, I end up having a list of lists of ProductSold
. I need to merge these lists and return only one. How to proceed?
I put in . Netfiddle an example: https://dotnetfiddle.net/CYFmjD
– Rovann Linhalis
I included in the answer your example, thanks man! I will start posting the answers with . Netfiddle also to increase the quality, thanks!
– Gustavo Santos
Kra about 3 minutes ago I found here, but thank you very much, that’s exactly what I was hunting xD
– LeandroLuk