ASP.NET Core OData $expand with FluentValidation not working

Viewed 151

I'm trying to query with OData using the $expand operator but when using AbstractValidator inheritance, I'm receiving a System.InvalidOperationException: When called from 'VisitLambda', rewriting a node of type 'System.Linq.Expressions.ParameterExpression' must return a non-null value of the same type. Alternatively, override 'VisitLambda' and change it to not visit children of this type. However without AbstractValidator inheritance, the query go successfully.

The request I'm trying to execute is: https://localhost:44316/developer/oncontextpaging?$expand=Goal

The full code is on my github, the configuration is already set, just need to run: update-database and simulate the above request. https://github.com/adlerpagliarini/ODataSamples/tree/1643ca615de346613081c34a58f1166ec741c42b

public abstract class Identity<TEntity> : AbstractValidator<TEntity>
{
    protected Identity() { }
    public int Id { get; set; }
}

public class Developer : Identity<Developer>
{
    public string Name { get; set; }
    public Goal Goal { get; set; }
}

public class Goal : Identity<Goal>
{
    public string Title { get; set; }
    public int UserId { get; set; }
}
0 Answers
Related