public class FinancialRecord : IAuditable
{
    .
    .
    .
    public double Amount { get; set; } // this is the larger amount that the sum of the installments amounts need to get to.

    public ICollection<Installment> Installments { get; set; }
    
    .
    .
    .
}
public class Installment : IAuditable
{
    
    public double Amount { get; set; }

    
    public Guid FinancialRecordId { get; set; }
    public FinancialRecord FinancialRecord { get; set; } = null!;
}

I'm working on a .NET 7 API that uses Entity Data Models (EDMs) to expose financial records with their associated installments using OData v4. I'm trying to apply the $apply aggregate transformation on the Installments entity set to compute the sum of the Installments Amount column for each financial record, and use this information to determine if the financial record is fully paid or not by comparing it with the Financial Records Amount.

Here's the query I'm using:

https://localhost:7046/odata/FinancialRecords/?$expand=Installments($apply=aggregate(Amount with sum as Total))&$count=true&$filter=Installments/Total eq Amount and IsDeleted eq false&$orderby=PaidOn desc&$skip=0&$top=12

However, this query fails with the following error:

The parent value for a property access of a property 'Total' is not a single value. Property access can only be applied to a single value.

It seems that this error is related to accessing the computed "Total" property from the Installments entity set. Is there a way to fix this error and retrieve the aggregate sum of the Amount column for each Installment to determine if the financial record is fully paid or not?

0

There are 0 best solutions below