Using LINQ to convert List to List

前端 未结 5 972
长发绾君心
长发绾君心 2020-12-14 05:49

I have 2 classes which have some identical properties. I stock into a list properties from 1st class, and after that, I want to take some needed properties and put them into

5条回答
  •  一个人的身影
    2020-12-14 06:16

    Just use Select:

    if(sil != null)
    {
       var iweil = sil.Select(item=>new InvoiceWithEntryInfo()
                {
                    IdIWEI = item.ID,
                    AmountIWEI = item.Amount,
                    DateIWEI = item.Date
                }).ToList();
    }
    

提交回复
热议问题