Return list of specific property of object using linq

倾然丶 夕夏残阳落幕 提交于 2019-11-30 03:06:29
var list = stockItems.Select(item => item.StockID).ToList();

You could also do it like this:

ids = stockItems.ConvertAll<Guid>(o => o.StockID);
user2259416

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());
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!