Given a class like this:
public class Stock
{
public Stock() {}
public Guid StockID { get; set; }
public string Description { get; set; }
}
How about something like this? Can this be simplified?
List<TranCode> alltrans = new List<TranCode>();
foreach (var bh in obj1.obj2WithCollection.obj2Collection)
{
alltrans.AddRange(bh.obj3WithCollection.Select(e => e.TransactionCode).ToList());
}
You could also do it like this:
ids = stockItems.ConvertAll<Guid>(o => o.StockID);
var list = stockItems.Select(item => item.StockID).ToList();