【发布时间】:2014-10-06 15:23:53
【问题描述】:
我们有一个包含嵌套列表的列表,即。
public class Question
{
public string Question { get; set;}
public List<Tag> Tags { get; set; }
}
public class Tag
{
public string TagName { get; set;}
public string TagDescription { get; set;}
}
然后我们有一个 GetQuestions() 返回问题列表的过程
public List<Tag> QuestionTags(int Type)
{
DAQuestions da = new DAQuestions();
var t = (from d in da.GetQuestions(Type)
)
select d.Tags).ToList();
}
我们正在努力实现它以返回 1 个明确的标签列表(无重复)。
我们现在返回的是一个
List<List<Tag>>
【问题讨论】:
-
使用
SelectMany来展平你的List<List<Tag>>并实现IEqualityComparer<Tag>以从该列表中获取不同的值。见:msdn.microsoft.com/en-us/library/vstudio/…
标签: c# linq asp.net-mvc-4