【问题标题】:how to convert a ienumerable to list in converter mapping properties如何将 ienumerable 转换为转换器映射属性中的列表
【发布时间】:2016-08-25 00:05:42
【问题描述】:
我有一个对象如下。
public class person
{
public int ID { get; set; }
public string name { get; set;}
}
我有一个转换器,可以将 Ienumerable 转换为该对象的列表。 (通过从那里映射这些 ID 和名称(它们也只有 ID 和名称)。怎么办?
【问题讨论】:
标签:
c#
asp.net
.net
c#-4.0
linq-to-sql
【解决方案1】:
如果你有
using System.Linq;
...您应该自动为任何IEnumerable<> 提供.ToList() 扩展方法:
IEnumerable<person> people = SomeMethod();
List<person> peopleList = people.ToList();