using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class News : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { AzrebiGeDataContext dc = new AzrebiGeDataContext(); // Select big news var q = (from na in dc.NewsAndArticles where na.CatID == 2 orderby na.date descending select na).Take(1); RepeaterBigNews.DataSource = q; RepeaterBigNews.DataBind(); //select 4 last added news (bottom) var q4news = (from na in dc.NewsAndArticles where na.CatID == 2 join sc in dc.SubCategories on na.SubID equals sc.SubID orderby na.date descending select new { ID = na.NAID, na.SubID, Title = na.NATitle, Short = na.NAShort, Date = na.NADate, na.img, Subname = sc.SubName }).Take(5).Skip(1); Repeater4news.DataSource = q4news; Repeater4news.DataBind(); // select Tops var qTops = (from na in dc.NewsAndArticles where na.CatID == 2 orderby na.hits descending select new { na.NAID, Title = na.NATitle }).Take(7); RepeaterTops.DataSource = qTops; RepeaterTops.DataBind(); // new posts and comments var newComments = (from na in dc.NewsAndArticles join co in dc.Comments on na.NAID equals co.NAID join u in dc.aspnet_Users on co.UserID equals u.UserId where na.CatID == 2 select new { na.NAID, na.NATitle, co.PostDate, u.UserName }).Take(5); RepeaterNewComments.DataSource = newComments; RepeaterNewComments.DataBind(); var fo = new ForumDataContext(); var newPosts = fo.yaf_topic_latest_vakho(5, 1); RepeaterNewPosts.DataSource = newPosts; RepeaterNewPosts.DataBind(); } }