Beispiel #1
0
        public IList<Tag> GetTags()
        {
            var result = new List<Tag>();

            var sessionsTags = from t in _dbContext.Tags
                               select new
                               {
                                   t.ID,
                                   t.TagName,
                                   SessionsCount = _dbContext.Sessions.Count(s => s.Tag_ID == t.ID)
                               };

            foreach (var tag in sessionsTags)
            {
                var tg = new Data.Tag() { ID = tag.ID, TagName = tag.TagName };
                var count = tag.SessionsCount;
                result.Add(tg.Map(count));
            }

            return result;
        }