SqlQuery SUM Postgres DB 中的值(原始 SQL 查询)

问题描述 投票:0回答:0

我正在尝试在 .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# 之外工作正常。

c# postgresql entity-framework-core npgsql
© www.soinside.com 2019 - 2024. All rights reserved.