Skip to content

Problem accessing properties in class extending IEnumerable #694

Description

@CheloXL

I have the following code:

class Permit {
    public VehicleHistory Vehicles {get...}
}

class VehicleHistory : IEnumerable<PermitVehicle> {
    public IEnumerable<Vehicle> Approved {get...}
}

record PermitVehicle {
    public required Vehicle Value { get; init; }
    public  required ApprovalStatus Status { get; init; }
}

And now, passing an instance of Permit to a template like {% for vehicle in Permit.Vehicles.Approved %} {{ vehicle.Value.Plate }} {% endfor %} renders nothing. It seems that fluid detects that Vehicles is an IEnumerable and stop trying to get the next property. Of course iterating over Vehicles works, but that makes me replicate the same code I have in Approved into the template.

Not sure if this is by design, or a problem in the template system.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions