2013-07-18 75 views
1

您好我有情况下,我从我的数据库获取数据,它看起来像这样的一组行:组基于列

enter image description here

我第一次使用实体框架数据库和存储过程来得到这个data.This是我找回型号:

public partial class GetELearningSessionsForStudent_Result 
{ 
    public int LessonNumber { get; set; } 
    public string LessonTitle { get; set; } 
    public Nullable<int> Status { get; set; } 
    public Nullable<System.DateTime> TargetDate { get; set; } 
    public string EventTitle { get; set; } 
} 

现在我想能组LessonNumber并把它作为一个重点,这将包含以下内容:

 KEY         Data 
{LessonNumber AND LessonTitle} {Status , TargetDate , EventTitle} 

我一直在尝试这样做几个小时,感觉我是somehoe缺少的东西。 我该如何做到这一点?

回答

1

这是你在找什么?

listOfItems.GroupBy(key => new { key.LessonNumber, key.LessonTitle }, 
    data => new {data.Status, data.TargetDate, data.EventTitle});