A: 

I think the problem is with the grouping construct. Try extract the data first (so there is not need to go via properties), then group by the extracted data.

IOW, try write the LINQ like would for the SQL.

leppie
+3  A: 

Instead of joining all tables in group by you can join the given tables by yourself. Can you try this;

from s in db.ForumStatsSet
join t in db.Topics on t.TopicId == s.TopicId
join f in db.Forums on f.ForumId == t.ForumId
join fg in db.ForumGroups on fg.ForumGroupId == f.ForumGroupId
where s.LogDate >= date1 && s.LogDate <= 
group s by new { t.TopicId, t.subject, f.forumName, t.datum, fg.name, f.forumID } into g
orderby g.Count() descending
select new TopicStatsData
{
 TopicId = g.Key.topicID,
 Count = g.Count(),
 Subject = g.Key.subject,
 ForumGroupName = g.Key.name,
 ForumName = g.Key.forumName,
 ForumId = g.Key.forumID
 });

ps: There may be some errors, but logically it should be correct!

yapiskan
Thanks, i can't manage to do a join do. The old LINQ to SQL way where you just add multiple from clauses like from s in db.ForumStatsSetfrom t in s.TopicDoesnt work and i do not have any ID's to do the join on since that is "removed" buy the model .. hmm .. im confused ..
Stuck
Solved it now, i made the join in the wrong order ..
Stuck