ASP中浏览次数最多的文章 [英] Most Viewed Articles in ASP
问题描述
大家好!
我正在使用C#为ASP中的某人开发一个新文章网站,但是有一个问题,我想实现有时被称为(五个最受欢迎文章)的(五个最受欢迎的文章)我该怎么办??
如果没有,则代码可能会在LINQ中,然后在SQL Server 2008 R2中直接查询中
pleaaaaaaaaaaaaaaaaaaase 帮助我
Hi Guys!
I am in developing a new articles website for someone in ASP using C# but there is a problem, that i want to implement the (Five most Viewed Articles) sometimes called (Five Most Popular Articles) How i can???
the code may in LINQ if not then in Straight forward Querying with SQL Server 2008 R2
pleaaaaaaaaaaaaaaaaase help me
推荐答案
在LINQ中尝试以下操作:
Try the following in LINQ:
var list = (from article in ArticleTable
where <apply your condition>
orderby article.LastViewedTime
select article ).Take(5);
浏览以下链接以获取有关LINQ的更多详细信息:
101个LINQ示例
LINQ to SQL-选择前N个行
对于LINQ的TOP/LIMIT支持
Navigate the following links for further details on LINQ:
101 LINQ Samples
LINQ to SQL - Select Top N Rows
TOP/LIMIT Support for LINQ
SELECT TOP 5 ArticleTitle, ArticleInfo
FROM ArticleTable
ORDER BY TimesViewed DESC
假设您有ArticleTable,并且TimesViewed Column跟踪了查看文章的次数.SQL中的TOP关键字将能够根据您提供的计数来获取记录,在您的情况下为5.
Lets say you have ArticleTable and TimesViewed Column keeps track of how many times article has been viewed.The TOP Keyword in SQL will be able to fetch the record based on the count you supply,in your case it is 5.
这篇关于ASP中浏览次数最多的文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!