How can i group by in Linq?

Viewed 34

The Tags class is

public class Tags
    {
        public int TagId;
        public string Tag;
        public string TagLink;
        public int TagCount;
    }

and my query is

 var v = db.QuestionTags
           .GroupBy(n => n.Tag.Tag1)
           .Select(n => new Tags
           {
               Tag = n.Key,
               TagCount = n.Count()
           }
           )
           .OrderByDescending(n => n.TagCount);

The problem with the approach above is that i cannot map also the TagId and the TagLink. How can i fix that?

1 Answers
Related