Lamba表达式错误 [英] Lamba expression error
问题描述
当我们从下拉列表中选择价值时,我会尝试根据下拉值显示高价图表我试试这个
我尝试了什么:
[WebMethod]
public static string jqufunc( int year)
{
string res = [跨度>;
ProjectdbEntities a = new ProjectdbEntities();
var b = a.Catg_type;
// a.spstdinfo();
foreach ( var c in b)
{
res + = ' + c.Catg_type1 + ',;
}
res = res.Substring( 0 ,res.Length - 1 );
res + = ];
// 用于程序类型
var allprogs = a.Program_type;
string res2 = [跨度>;
foreach ( var pr in allprogs)
{
res2 + = {name:' + pr.Prog_name + ',;
// 年份
var yearget = a.Year_info;
foreach ( var yg in yearget)
{
res2 + = ' + yg.year + ',;
// for cat
var allcats = a.Catg_type;
res2 + = data:[;
foreach ( var ct in allcats)
{
res2 + = a.Std_info.Where(t = > t.Catg_id == ct。 Catg_id&& t.Prog_id == pr.Prog_id&& t.year_id = yg.year_id).Count()。ToString()+ < span class =code-string>,;
}
res2 = res2.Substring( 0 ,res2.Length - 1 跨度>);
res2 + = ];
res2 + = },;
}
res2 = res2.Substring( 0 ,res2.Length - 1 跨度>);
res2 + = ];
return res + * + res2;
}
}
这里的年份是int
当我在这条线上发生错误时
res2 + = a.Std_info.Where(t => t.Catg_id == ct.Catg_id&& t.Prog_id == pr.Prog_id&& t.year_id = yg.year_id)。Count()。ToString()+,;
错误:
无法将lambda表达式转换为类型'string',因为它不是委托类型
委托'System.Func< webapplication1.std_info, int,bool>'不带1个参数
运算符'&&'不能应用于'bool'和'int?'类型的操作数'
那里有一个小的语法错误:
(t = > t。 Catg_id == ct.Catg_id&& t.Prog_id == pr.Prog_id&& t.year_id = yg.year_id)
看最后一部分你的情况......
<前lang =C#> t .year_id = yg.year_id
当然应该是
t .year_id == yg.year_id
when we select value from dropdown then i try to display highcharts according to dropdown value for this i try this
What I have tried:
[WebMethod]
public static string jqufunc(int year)
{
string res = "[";
ProjectdbEntities a = new ProjectdbEntities();
var b = a.Catg_type;
//a.spstdinfo();
foreach (var c in b)
{
res += "'" + c.Catg_type1 + "',";
}
res = res.Substring(0, res.Length - 1);
res += "]";
//for program type
var allprogs = a.Program_type;
string res2 = "[";
foreach (var pr in allprogs)
{
res2 += "{name: '" + pr.Prog_name + "',";
//for year
var yearget = a.Year_info;
foreach (var yg in yearget)
{
res2 += "'" +yg.year + "',";
//for cat
var allcats = a.Catg_type;
res2 += "data:[";
foreach (var ct in allcats)
{
res2 += a.Std_info.Where(t => t.Catg_id == ct.Catg_id && t.Prog_id == pr.Prog_id && t.year_id=yg.year_id).Count().ToString() + ",";
}
res2 = res2.Substring(0, res2.Length - 1);
res2 += "]";
res2 += "},";
}
res2 = res2.Substring(0, res2.Length - 1);
res2 += "]";
return res + "*" + res2;
}
}
here year is in int
when i build error occur on this line
res2 += a.Std_info.Where(t => t.Catg_id == ct.Catg_id && t.Prog_id == pr.Prog_id && t.year_id=yg.year_id).Count().ToString() + ",";
Errors:
Cannot convert lambda expression to type 'string' because it is not a delegate type
Delegate 'System.Func<webapplication1.std_info,int,bool>' does not take 1 arguments
Operator '&&' cannot be applied to operands of type 'bool' and 'int?'
A tinny syntax error there:
(t => t.Catg_id == ct.Catg_id && t.Prog_id == pr.Prog_id && t.year_id = yg.year_id)
Look at the last part of your condition...
t.year_id = yg.year_id
It should be of course
t.year_id == yg.year_id
这篇关于Lamba表达式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!