0
我開發的新聞網站在asp.net 4.0與C#中,實體框架5 &的SQLServer 2008顯示新聞
後閱讀新聞我展示基於來自其他新聞
匹配標籤的相關新聞var article = (from c in ctx.Articles where c.ArticleID == "10" select c).SingleOrDefault();
var tags = new List<string>();
string[] words = article.Tags.Split(',');
foreach (string word in words)
{
if (word != "") { tags.Add(word.Trim()); }
}
最新消息有以下標籤: 太陽,月亮,星星
var relatedNews = (from c in ctx.Articles where tags.Contains(c.Tags) select c).Take(10);
如果其他消息有一個標籤「,如太陽「它工作正常 但是如果它有‘太陽星系’或多個標籤,這是行不通的