I am working on a tag cloud application. There are 3 database tables.
Content: ContentID, Text
Tag: TagID, Name
TagRelation: TagRelationID, TagID, ContentID
The code below is wrong. Because ‘Contains’ clause doesn’t take a list of parameters like the ‘IN’ SQL clause. Is there an alternative clause that I can use to make this code work?
public List<Content> GetTagArticles(String tagName)
{
var relations = db.TagRelation.Where(t => t.Tag.Name == tagName).ToList();
var contents = db.Content.Where(c => c.TagRelation.Contains(relations)).ToList();
return contents.ToList();
}
Try the following: