无法将SQL查询转换为Linq to实体

无法将SQL查询转换为Linq to实体,linq,entity-framework-4.1,Linq,Entity Framework 4.1,我有以下SQL查询: SELECT Comment, JD, Jurisdiction, RegStatus, Region, SPDR_NAME FROM dbo.Registered_status_by_year GROUP BY Comment, JD, SPDR_NAME, Region, Jurisdiction, RegStatus HAVING (Region = @Region) ORDER BY JD 我正在尝试将它转换为linq到实体。到目前为止,我有以下几点: va

我有以下SQL查询:

SELECT Comment, JD, Jurisdiction, RegStatus, Region, SPDR_NAME 
FROM dbo.Registered_status_by_year 
GROUP BY Comment, JD, SPDR_NAME, Region, Jurisdiction, RegStatus 
HAVING (Region = @Region) ORDER BY JD
我正在尝试将它转换为linq到实体。到目前为止,我有以下几点:

var result = (from x in myEntities.IRTStatusByYearSet
                          group x by new { x.Comment, x.JD, x.SPDR_NAME, x.Region, x.Jurisdiction, x.RegStatus } into g
                          select g);
问题是我似乎不能使用“orderby”,因为“g”没有任何作为列名的“属性”


有人知道我该怎么做吗?我已经寻找了使用分组进行排序的示例,但所有示例都只显示了按一件事进行分组,或者按分组中项目的“计数”排序,而不是按其他值进行排序。

您是否尝试过
orderby g.Key.JD

var result = (from x in myEntities.IRTStatusByYearSet
              group x by new { x.Comment, x.JD, x.SPDR_NAME, x.Region, x.Jurisdiction, x.RegStatus } into g
              orderby g.Key.JD
              select g);

完全是这样。。非常感谢你!10分钟结束后,我会将此标记为已回答。=)