Applying userAuthId as AutoFilter

I’m trying to understand how to correctly use AutoFilter to apply the currently logged in users Id to my query. However, the best I’ve got is the following, which has an error due to type miss match. The AppUserId field here links to the IAuthRepo (custom)

public class Aircraft : AuditBase, IAppUserFilter
    public int Id { get; set; }
    public string Registration { get; set; }
    public int AppUserId { get; set; }

public interface IAppUserFilter
    int AppUserId { get; set; }

[Tag("Aircraft"), Description("Find Aircraft")]
[Route("/aircraft", "GET")]
[Route("/aircraft/{Id}", "GET")]
[AutoFilter(QueryTerm.Ensure, nameof(IAppUserFilter.AppUserId), Eval = "userAuthId")]
public class QueryAircraft : QueryDb<Aircraft> 
    public int? Id { get; set; }

I tried adding |> toInt but it didn’t work (or i used it wrong).

The |> is only available in statement blocks, for #Script expressions try userAuthId.toInt().

Yep. that worked! Thanks again.

Now is there an easier way to globally apply this to all instead of decorating every autoquery with the filter?

Have a look at the docs on Apply Generic CRUD Behaviors which lets you define behaviors that can apply multiple attributes which is how the built-in [AutoApply(Behavior.*)] apply its behaviors.