【问题标题】:Exception: must be reducible node in Entity Core例外:必须是 Entity Core 中的可简化节点
【发布时间】:2018-01-08 18:23:31
【问题描述】:

当我尝试“连接”多个使用导航属性的 IQueryable where 子句时,我在 Entity Core 1.1.0 中遇到异常。

简单示例(不是我的实际代码):

 public List<ProjectSummaryDto> TestRelation(string s)
    {
            var query = _context.TechnologicallyProject
            .WhereIf(! string.IsNullOrWhiteSpace(s), q => q.Document.Title.Contains(s))
            .ProjectTo<ProjectSummaryDto>();

        return query.ToList();  //Exception Message: must be reducible node
    }

堆栈跟踪:

在 System.Linq.Expressions.Expression.ReduceAndCheck() 在 System.Linq.Expressions.Expression.ReduceExtensions() 在 System.Linq.Expressions.Compiler.StackSpiller.RewriteExtensionExpression(表达式 expr, 栈栈) ....

但是,当 Contains(Title) 到 Equlas(id) 发生变化时,它可以正常工作

 public List<ProjectSummaryDto> TestRelation(int s)
    {

        var query = _context.TechnologicallyProject
            .WhereIf(s != 0 , q => q.Document.Id.Equals(s))
            .ProjectTo<ProjectSummaryDto>();

        return query.ToList();
    }

【问题讨论】:

  • 在每种情况下你传递的都是“s”吗?

标签: c# entity-framework linq


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2019-02-27
    • 1970-01-01
    • 2021-03-09
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 2021-04-25
    • 1970-01-01
    相关资源
    最近更新 更多