如何按ToLower()分组? [英] How to group by ToLower()?

查看:42
本文介绍了如何按ToLower()分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我读取了一个csv文件.在此csv文件中,有不同的功能及其持续时间.现在,我想按函数名称对结果进行分组,但是有时函数的名称是相同的,但有时字母是大写和小写,例如:examplevalueEXampleValue.

In my project I read a csv file. In this csv file there are different functions and their duration. Now I want to group my result by the function name but sometimes the name of the function is the same but the letters are sometimes upper and lower case like: examplevalue, EXampleValue.

在此示例中,这将是2个不同的功能. 为了解决这个问题,我想将这些函数转换为小写.我尝试过这种方法,但是它不起作用:

In this example this would be 2 different functions. To solve this problem I want to convert these functions into lower case. I tried like this but it is not working:

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

推荐答案

您可以将比较器传递给GroupBy,在这种情况下,您可以使用现有的:

You can pass a comparer to GroupBy, in this case you can use an existing:

.GroupBy(x =>x.Function, StringComparer.OrdinalIgnoreCase);

这篇关于如何按ToLower()分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆