联表查询默认值 返回

SqlSugar 待处理
1 305
var autoInvoiceTasks = await db.Queryable<CgStation>()
    .InnerJoin<CgOrderInfo>(rightQuery,(station, order) =>
        station.Id == order.stationid && order.IsInvoiced!=true)
    .LeftJoin<CgAppUserInvoiceInfo>((station, order, template) =>
        order.clientid == template.userid)
    .Where((station, order, template) =>
        station.enableChargeAutoInvoice&&order.UserPayAmount>0&&order.status==Enums.OrderStatus.PowerEnd)
    .Select((station, order, template) => new AutoInvoiceTaskDto
    {
        orderId = order.Id,
        clientphone = order.clientphone,
        operatorid = order.operatorid.Value,
        startchargeseq = order.startchargeseq,
        userId = order.clientid.Value,
        TemplateId = SqlFunc.IsNull(template.Id, YitIdHelper.NextId()),
        headuptype = SqlFunc.IsNull(template.headuptype, 0),
        gmfMc = SqlFunc.IsNull(template.gmfMc, order.clientphone),
        gmfNsrsbh = template.gmfNsrsbh,
        gmfDz = template.gmfDz,
        gmfDh = template.gmfDh,
        gmfYh = template.gmfYh,
        gmfYhZh = template.gmfYhZh,
        bz = template.bz,
        totalelemoney = order.totalelemoney,
        totalsevicemoney = order.totalsevicemoney,
        UserPayAmount = order.UserPayAmount,
        totalele = order.totalele,
        endtime = order.endtime,
    })
    .ToListAsync();

如果

CgAppUserInvoiceInfo

表中没有信息是null怎么实现判断没有值给一个默认值

热忱回答1