带有FluentValidation的ASP.NET Core OData $ expand不起作用

问题描述

我正在尝试使用 $ expand 运算符向OData查询,但是在使用 AbstractValidator 继承时,我收到了 system.invalidOperationException:调用时从“ VisitLambda”中,重写“ System.Linq.Expressions.ParameterExpression”类型的节点必须返回相同类型的非null值。或者,覆盖“ VisitLambda”并将其更改为不访问该类型的子对象。但是,如果没有 AbstractValidator 继承,查询将成功进行。

我要执行的请求是: https:// localhost:44316 / developer / oncontextpaging?$ expand = Goal

完整的代码在我的github上,配置已经设置,只需运行: update-database 并模拟上述请求。 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; }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)