Linq GroupBy如何返回分组到另一个列表中的对象集合?

Linq GroupBy如何返回分组到另一个列表中的对象集合?,linq,entity-framework,c#-4.0,Linq,Entity Framework,C# 4.0,在使用Linq对集合执行GroupBy之后,我很难尝试返回对象集合 具体来说,当我从EF4.1调用视图时,我有一个CurrentSegmentGroupDetail对象的集合。使用Lambda表达式,我通过SegmentGroup属性将CurrentSegmentGroupDetail对象分组。我得到的结果是包含CurrentSegmentGroupDetail对象的SegmetGroup列表。我遇到的问题是试图将分组结果集返回到列表类型 以下是我目前掌握的代码: public List

在使用Linq对集合执行GroupBy之后,我很难尝试返回对象集合

具体来说,当我从EF4.1调用视图时,我有一个CurrentSegmentGroupDetail对象的集合。使用Lambda表达式,我通过SegmentGroup属性将CurrentSegmentGroupDetail对象分组。我得到的结果是包含CurrentSegmentGroupDetail对象的SegmetGroup列表。我遇到的问题是试图将分组结果集返回到列表类型

以下是我目前掌握的代码:

    public List<CurrentSegmentGroupDetail> GetSegmentGroupsForReconciliation()
    {
        using (var context = new PricingContext())
        {
            var segmentGroups =
                context.CurrentSegmentGroupDetails.GroupBy(s => s.SegmentGroup).Select(y => y);

            return segmentGroups;
        }
    }
public List getSegmentGroupsForreConference()
{
使用(var context=new PricingContext())
{
var分段组=
context.CurrentSegmentGroupDetails.GroupBy(s=>s.SegmentGroup)。选择(y=>y);
返回段组;
}
}
以下是我尝试将结果集传递到我的列表对象时遇到的异常:

无法将类型“System.Linq.IQueryable>”隐式转换为“System.Collections.Generic.List”

如果您能在这方面给予帮助,我将不胜感激。

ToList()

return segmentGroups.ToList();