I have an entity name "Forum" with number of properties.
I also created a partial class "Forum" that encapsulates Extra properties like int PostCount.
List<Forum> lForum = null;
lForum= (from forum in Forums
join post in Posts on forum equals post.Forum into postsInForum
select new
{
Forum = forum, //Fill all
PostCount = postsInForum.Count(post => post.ShowIt == 1) //Fill the "extra" property
}).ToList();
How can I do it?
Update
If I use a new Class for presentation "ForumAndCount" what will have the same properties as the Forum and an extra property "PostCount" , is it possible to project all Forum's fields on it at once or I must set all of them one by one:
select new ForumAndCount
{
ForumID= forum.ForumID,
ForumTitle = forum.Title,
ForumImg = forum.Img,
Forum...
.
PostCount = postsInForum.Count(post => post.ShowIt == 1)
}
I can ofcourse Create Forum type property in my ForumAndCount, but i don't want that. })