我想在C#中使用LINQ創建標籤雲。我從來沒有使用LINQ,所以我得到了一些語法錯誤。有人可以幫我修復我的代碼嗎?在此先感謝您的幫助!C#LINQ標籤雲
private void BindTagCloud()
{
var tagSummary = from af in db.AgileFactors
join psf in db.ProjectStoryFactors
join s in db.Stories
join pim in db.ProjectIterationMembers
join i db.Iteration
join p db.Project
where p.ProjectID == proj_id
p.ProjectID == i.ProjectID and
i.ProjectIterationID == pim.ProjectIterationID and
pim.ProjectIterationMemberID == s.ProjectIterationMemberID and
s.StoryID == psf.StoryID and
psf.AgileFactorID == af.AgileFactorID
group af by af.Name into tagGroup
select new
{
ID = af.AgileFactorID,
Total = psf.Count()
};
var tagCloud = from psf in tagSummary
where psf.AgileFactorID == tagSummary.ID
select new
{
Name = psf.Name,
ID = psf.AgileFactionID,
Count = psf.Count(),
weight = Count/tagSummary.Total * 100
};
ListView1.DataSource = tagCloud;
ListView1.DataBind();
}
如果您發佈了錯誤以及它們發生的位置,這將有所幫助 – Karel 2011-01-23 22:06:01