You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GraphQL Hot Chocolate 12中countEarnings参数错误排查求助

问题修复说明

1. GraphQL查询参数大小写不匹配

错误提示的核心原因是参数名大小写不一致:

  • 后端countEarnings方法的参数名为PriceBay(首字母大写)
  • 你的GraphQL查询里写的是priceBay(首字母小写)

GraphQL参数名区分大小写,修正后的查询如下:

query{
  countEarnings(PriceBay: 3540, PriceSell: 5050, taxValue: 23)
}

2. C#代码变量拼写错误

你的CountEarnings方法存在变量名拼写错误:参数定义的是PriceBay,但方法体内误用了未定义的PriceBuy,这会导致编译失败。修正后的C#代码:

public double RemoveTaxVat(double price, double taxVat)
{
    taxVat = taxVat / 100;
    taxVat = taxVat + 1;
    price = price / taxVat;
    return price;
}

public double CountEarnings(double PriceBay, double PriceSell, double taxValue)
{
    double earnings = RemoveTaxVat(PriceSell, taxValue) - PriceBay;
    return earnings;
}

内容的提问来源于stack exchange,提问作者xoreee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 16:25:09