Working with Entity Framework in ASP.Net MVC 4, and need to use linq to output a line of information.
I have an ArticleView table and an Article table. I need to output an article with the most activity within a 24 hour period.
Here's my ArticleView table:
int ArticleID
DateTime ViewCreated
Article table:
int ID
string title
Sample Data:
ArticleView:
ArticleID ViewCreated
2 4/8/2014 1:48:40 PM
2 4/8/2014 1:50:40 PM
2 4/8/2014 1:55:20 PM
3 4/8/2014 12:07:30 PM
Note: ViewCreated is automatically generated once someone views an article.
Article:
ID Title
2 Article2
3 Article3
Expected Output:
Article with the most activity within 24 hours is:
Article2(3)
What I have to work with:
var articles = db.Articles;
var articleviews = db.ArticleViews;
Just not sure how to approach this.