C#LINQ标签云
我正在尝试使用LINQ在C#中创建标记云。我以前从未使用过LINQ,因此我遇到了一些语法错误。有人能帮我修改代码吗?提前感谢您的帮助C#LINQ标签云,c#,linq,linq-to-sql,C#,Linq,Linq To Sql,我正在尝试使用LINQ在C#中创建标记云。我以前从未使用过LINQ,因此我遇到了一些语法错误。有人能帮我修改代码吗?提前感谢您的帮助 private void BindTagCloud() { var tagSummary = from af in db.AgileFactors join psf in db.ProjectStoryFactors join s in db.Stories join
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();
}
林克!=TSQL;每个
和
都应该是C#、和&
;每个连接
应立即指定左右部分(使用等于
),即
join newAlias in newSet on existingAlias.Key equals newALias.Key
如果您想编写TSQL,这很好-只需使用
.ExecuteQuery(TSQL,args)
LINQ!=TSQL;每个和
都应该是C#、和&
;每个连接
应立即指定左右部分(使用等于
),即
join newAlias in newSet on existingAlias.Key equals newALias.Key
如果您想编写TSQL,那很好-只需使用
.ExecuteQuery(TSQL,args)
谢谢Marc,我通过修复连接消除了大部分错误。还有4个错误:
select new {
ID = af.AgileFactorID,
Total = psf.Count()
};
1) 当前上下文中不存在名称af,
2) 名称psf在当前上下文中不存在
var tagCloud = from psf in tagSummary where psf.AgileFactorID == tagSummary.ID
1) 错误62“AnonymousType#1”不包含“AgileFactorID”的定义,并且找不到接受“AnonymousType#1”类型的第一个参数的扩展方法“AgileFactorID”(是否缺少using指令或程序集引用?)
2) 错误63“System.Collections.Generic.IEnumerable”不包含“ID”的定义,并且找不到接受类型为“System.Collections.Generic.IEnumerable”的第一个参数的扩展方法“ID”(是否缺少using指令或程序集引用?谢谢Marc,我通过修复联接消除了大多数错误。还有4个错误:
select new {
ID = af.AgileFactorID,
Total = psf.Count()
};
1) 当前上下文中不存在名称af,
2) 名称psf在当前上下文中不存在
var tagCloud = from psf in tagSummary where psf.AgileFactorID == tagSummary.ID
1) 错误62“AnonymousType#1”不包含“AgileFactorID”的定义,并且找不到接受“AnonymousType#1”类型的第一个参数的扩展方法“AgileFactorID”(是否缺少using指令或程序集引用?)
2) 错误63“System.Collections.Generic.IEnumerable”不包含“ID”的定义,并且找不到接受“System.Collections.Generic.IEnumerable”类型的第一个参数的扩展方法“ID”(是否缺少using指令或程序集引用?)如果您发布错误、错误发生的位置以及where语句错误,这将非常有用。我使用了“&&”而不是“and”,这修复了一些错误。剩余错误:上应有上下文关键字;预期上下文关键字等于…如果您发布错误、错误发生的位置以及where语句错误,这将非常有用。我使用了“&&”而不是“and”,这修复了一些错误。剩余错误:上应有上下文关键字;预期上下文关键字等于。。。