using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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();
}
}