Last post Apr 22, 2016 08:08 AM by omerdemir
Apr 22, 2016 05:35 AM|omerdemir|LINK
I have Table which storing articleId and topicId
Id ArticleId TopicId Time
and I've another table with 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 advance
Apr 22, 2016 06:34 AM|raju dasa|LINK
Your join code seems fine, check if TopicId which are are passing in Where condition is existing in ArticleTopics table.
Apr 22, 2016 06:58 AM|omerdemir|LINK
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 correctly
Apr 22, 2016 08:08 AM|omerdemir|LINK
My all Inner Joins was not available
Checked my records and now working good.