Something like this:
var viewsById = db.ArticleViews
.Where(av => av.ViewCreated >= startDateTime && av.ViewCreated < endDateTime)
.GroupBy(av => av.ArticleId)
.Select(g => new { ArticleId = g.Key, Count = g.Count() })
var highestCount = viewsById.Max(v => v.Count);
var topArticles = viewsById.Where(a => a.Count == highestCount);
var topArticle = topArticles.First();
var message = String.Format("Article id: {0}, views: {1}",
topArticle.ArticleId, topArticle.Count);
- Filter the views to be within the specified date range.
- Group them by article Id.
- Make an anonymous object of each one, storing the article Id and the count of views for that article.
- Take the one with the highest count.