Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 以小写形式返回函数名_Javascript_C#_Asp.net Mvc - Fatal编程技术网

Javascript 以小写形式返回函数名

Javascript 以小写形式返回函数名,javascript,c#,asp.net-mvc,Javascript,C#,Asp.net Mvc,在我的项目(ASP.net MVC)中,我必须返回函数的名称(我读入的CSV文件),以小写形式。因为现在我已经对函数进行了分组,它返回同名函数(有时小写,有时大写)。我不知道如何解决这个问题 //家庭控制器 公共列表数据() { Console.WriteLine(“描述函数数据”); var descItemsStamp=db.ChartDatas .GroupBy(x=>new{x.Function}); var descItems=descItemsStamp .选择(x=>new De

在我的项目(ASP.net MVC)中,我必须返回函数的名称(我读入的CSV文件),以小写形式。因为现在我已经对函数进行了分组,它返回同名函数(有时小写,有时大写)。我不知道如何解决这个问题

//家庭控制器
公共列表数据()
{
Console.WriteLine(“描述函数数据”);
var descItemsStamp=db.ChartDatas
.GroupBy(x=>new{x.Function});
var descItems=descItemsStamp
.选择(x=>new DescFunctionDataDTO
{
function=x.Select(b=>b.function).Distinct(),
FunctionalVG=Math.Round(x.平均值(y=>y.持续时间),2),
})
.OrderByDescending(x=>x.vg)
.ToList();
退货项目;
}
//DTO
公共类DescFunctionDataDTO
{
公共IEnumerable函数{get;set;}
公共双函数vg{get;set;}
}
//JS文件
函数showDescDuration(){
$.getJSON(`/Home/DescFunctionData`)
。然后(数据=>{
控制台日志(数据);
$(“#rankingMax”).find(“tr:gt(0)”).fadeOut().empty();
var i=1;
对于(数据项){
log('loop');
$('').appendTo('#rankingMax')
.append($('').html(“#”+i))
.append($('').html(item.function))
.append($('').html(item.functionavg+“ms”);
i++;
}
});
}

您可以像这样使用预定义函数string.ToLower()

var descItemsStamp = db.ChartDatas
    .GroupBy(x => new { x.Function });

var descItems = descItemsStamp
    .Select(x => new DescFunctionDataDTO
    {
        function = x.Select(b => b.Function.ToLower()).Distinct(),
        functionavg = Math.Round(x.Average(y => y.Duration), 2),
    })
    .OrderByDescending(x => x.functionavg)
    .ToList();
return descItems;

你试过
item.function.toLowerCase()
?看起来你的同学已经问过@OwenPauling哈哈,谢谢!您能告诉我如何过滤每个函数只有一个示例出现的函数吗。e、 g仅1次。索引,仅1次。登录,。@MarkoKopuz首先读取
var descItemsStamp = db.ChartDatas
    .GroupBy(x => new { x.Function });

var descItems = descItemsStamp
    .Select(x => new DescFunctionDataDTO
    {
        function = x.Select(b => b.Function.ToLower()).Distinct(),
        functionavg = Math.Round(x.Average(y => y.Duration), 2),
    })
    .OrderByDescending(x => x.functionavg)
    .ToList();
return descItems;