Answered by:
Join Table

Question
-
User-1305858305 posted
Hello
I have Table which storing articleId and topicId
ArticleTopics
Id ArticleId TopicId Time
and I've another table with Articles
Articles
ArticeId CategoryId HostId ... ... ...
I want to join ArticleTopics table, look up for specific topic id which recorded with articles and retrieve this articles from Articles Table.
var results = from article in dataContext.Articles .Where(t => t.DateAdded <= DateTime.Now.AddHours(-time)) join h in dataContext.Hosts on article.HostID equals h.HostId join c in dataContext.Categories on article.CategoryId equals c.CategoryId join myvote in dataContext.Votes on article.ArticleId equals myvote.ArticleId into JoinedArticleVote from myvote in JoinedArticleVote.Where(v => v.UserId == userId).DefaultIfEmpty() select new ArticleWithVotingInfo() {
tried this but returning no value even there is one record
join articleTopics in dataContext.ArticleTopics on article.ArticleId equals articleTopics.ArticleId where articleTopics.TopicId == topicId
Thanks in advanceFriday, April 22, 2016 5:35 AM
Answers
-
User-1305858305 posted
My all Inner Joins was not available
Checked my records and now working good.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, April 22, 2016 8:08 AM
All replies
-
User527778624 posted
Hi,
Your join code seems fine, check if TopicId which are are passing in Where condition is existing in ArticleTopics table.
Friday, April 22, 2016 6:34 AM -
User-1305858305 posted
Thank you for reply,
I've topicList table with click which displaying topics and article count.
Its mean yes there is articles with this topic and topic id passing correctlyFriday, April 22, 2016 6:58 AM -
User-1305858305 posted
My all Inner Joins was not available
Checked my records and now working good.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, April 22, 2016 8:08 AM