在我的项目(ASP.net MVC)中,我必须以小写形式返回函数名称(我读入的 CSV 文件)。因为现在我已经对函数进行了分组,并且它返回具有相同名称的函数(有时是小写,有时是大写)。我不知道如何解决这个问题?
//HomeController
public List<DescFunctionDataDTO> DescFunctionData()
{
Console.WriteLine("DescFunctionData");
var descItemsStamp = db.ChartDatas
.GroupBy(x => new { x.Function });
var descItems = descItemsStamp
.Select(x => new DescFunctionDataDTO
{
function = x.Select(b => b.Function).Distinct(),
functionavg = Math.Round(x.Average(y => y.Duration), 2),
})
.OrderByDescending(x => x.functionavg)
.ToList();
return descItems;
}
//DTO
public class DescFunctionDataDTO
{
public IEnumerable<string> function { get; set; }
public double functionavg { get; set; }
}
//JS-File
function showDescDuration() {
$.getJSON(`/Home/DescFunctionData`)
.then(data => {
console.log(data);
$('#rankingMax').find("tr:gt(0)").fadeOut().empty();
var i = 1;
for (let item of data) {
console.log('loop');
$('<tr>').appendTo('#rankingMax')
.append($('<td>').html("#"+i))
.append($('<td>').html(item.function))
.append($('<td>').html(item.functionavg + " ms"));
i++;
}
});
}
ITMISS
相关分类