在LeftJoin的Select中添加自定义计算列无法正常返回 返回

SqlSugar 处理完成
1 106
DbContext.Queryable<Table1>()
  .LeftJoin(DbContext.Queryable<Table2>(),
       (t1, t2) => t1.LinkId = t2.Id)
  .Select((t1, t2) => new
  {
    t1.LinkId

    t1.Name,

     t2Exists = t2 != null,

    t2.Id,
    t2.Name
  })
  .ToList();

查询后会产生如下错误

Could not convert string to boolean: NULL. Path 't2Exists', line XX, position XX.

运行时: .NET 8.0

SqlSugar版本: 5.1.4.173


热忱回答1

  • fate sta fate sta VIP0
    1个月前

         t2Exists = t2.主键!=null,

    或者  int主键 t2Exists = t2.主键>0,

    0 回复