How to add to a list using Linq's aggregate function C#

前端 未结 1 1988
后悔当初
后悔当初 2021-02-15 08:09

I have a collection of objects of one type that I\'d like to convert to a different type. This can be done easily with foreach, but I\'d like to figure out how to use Linq\'s a

1条回答
  •  温柔的废话
    2021-02-15 08:44

    I think a call to Select combined with ToList() might be what you need here. For example:

    context.Items
      .Select(item => new DestinationType(item.A, item.B, item.C))
      .ToList();
    

    0 讨论(0)
提交回复
热议问题