Good code:
var query = (from s
in
db.ForumStatsSet
where s.LogDate >= date1 && s.LogDate <= date2
group s by
new
{
s.Topic.topicID, s.Topic.subject,
s.Topic.datum, s.Topic.Forum.forumID,
s.Topic.Forum.forumName,
s.Topic.Forum.ForumGroup.name } into g
orderby g.Count() descending
select
new
TopicStatsData
{
TopicId = g.Key.topicID,
Count = g.Count(),
Subject = g.Key.subject,
ForumId = g.Key.forumID,
ForumName = g.Key.forumName,
ForumGroupName = g.Key.name
});
var query = (from fg
in
db.ForumGroupSet
from f
in
fg.Forums
from t
in
f.Topics
from s
in
t.ForumStats
where s.LogDate >= date1 && s.LogDate <= date2
group s by
new
{ t.topicID,
t.subject,
t.datum,
f.forumID,
f.forumName,
fg.name } into g
orderby g.Count() descending
select
new
TopicStatsData
{
TopicId = g.Key.topicID,
Count = g.Count(),
Subject = g.Key.subject,
ForumId = g.Key.forumID,
ForumName = g.Key.forumName,
ForumGroupName = g.Key.name
});