有没有办法解决在 SForce Apex 中从 List<AggregateResult> 到 List<String> 的非法转换?

Is there a way to resolve Illegal conversion from List<AggregateResult> to List<String> in SForce Apex?

我正在尝试获取一个字段值,下面是代码,但我在 SForce 中遇到以下错误

Illegal conversion from List<AggregateResult> to List<String>


                public class PickListHandler {
                    @AuraEnabled
                    public static List<String> getLevel1(){


                       List<AggregateResult> groupedLevel1
                  = [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c];

                        for(AggregateResult  ar : groupedLevel1){                
                           System.debug('Level Value Is' + ar.get('Level_1__c'));

                        }

                        return groupedLevel1;
                    } 


                }

有人可以帮忙修复吗?

提前致谢

只需将函数的返回类型更改为 List :

public class PickListHandler {
    @AuraEnabled
    public static List<AggregateResult> getLevel1() {
        List<AggregateResult> groupedLevel1 =
            [SELECT Level_1__c, COUNT(Id) FROM Case_Type_Data__c GROUP BY Level_1__c];
        for(AggregateResult ar : groupedLevel1) {                
            System.debug('Level Value Is' + ar.get('Level_1__c'));
        }
        return groupedLevel1;
    } 
}