MappingField和Where组合使用的问题。 返回

SqlSugar 沟通中
2 377
该叫什么 L 发布于2026/3/11
悬赏:0 飞吻
Db.Queryable<WarehouseIn>()
.Includes(o => o.WarehouseInDetail, x => x.CompanyProduct, 
                y => y.Images.MappingField(img => img.CompanyID, () => y.CompanyID)
                             .Where(img => img.CompanyID == null || img.CompanyID == y.CompanyID)
                             .ToList())

上面这个写法。img.CompanyID == null  的条件不会生效


热忱回答2

  • fate sta fate sta VIP0
    2026/3/11

       .Where(img => img.CompanyID == null || img.CompanyID == y.CompanyID) 这个条件是错的吧。 where只能当前表作为条件

    0 回复
  • fate sta fate sta VIP0
    2026/3/11

    并且mappingfiled只能关系映射。

    0 回复