如何在 SqlKata 中转换和优化此 SQL 查询

How to convert and optimize this SQL query in SqlKata

我有这个 SQL 查询,我需要将它转换为 SqlKata

SELECT VVIAGGIO AS VIAGGIO, ISNULL(AEAN,'') AS EAN
FROM 
SALDI V INNER JOIN ARTICOLI A ON VARTI=AARTI
INNER JOIN ORDI OT ON VSTAB=OTSTAB AND VMAGA=OTMAGA AND VAGG=OTRAGG
  WHERE VORDI ='21'
  AND VHOST ='68'
ORDER BY VPROG, AARTI

我不知道如何构造它,因为这里是 ISNULL()INNER JOIN.. 我已经检查了 SqlKata select 指令。

关于如何在 SqlKata 中优化和转换此查询有什么建议吗?

这是您需要的:

var query = new Query("SALDI as V")
    .Join("ARTICOLI as A","A.ARTI","V.ARTI")
    .Join("ORDI as OT",j => j.On("OT.STAB","V.STAB")
          .On("V.MAGA","OT.MAGA")
          .On("V.AGG","OT.RAGG")
    )
    .Where("V.ORDI","21")
    .Where("V.HOST","68")
    .Select("V.VIAGGIO")
    .SelectRaw("ISNULL(V.AEAN,'') as EAN")
    .OrderBy("V.PROG", "A.ARTI")