我正在尝试在 .NET 7 中使用 SqlQuery 对一组值求和
var totalTime = await this.Context.Database.SqlQuery<int>($"SELECT \"SUM\"(extract(day from(NOW()-\"stripe_created_date\"))::integer) FROM stripe.\"subscription\" WHERE \"stripe_created_date\" >= {gte} and \"status\" <> 'incomplete_expired' and \"status\" <> 'incomplete' and \"status\" <> 'canceled'").FirstOrDefaultAsync();
我得到:
Npgsql.PostgresException: '42883: 函数 SUM(整数) 不存在
查询在 C# 之外工作正常。