如何在 LINQ Join 中使用 AND 运算符

BJ *_*tel 4 c# linq linq-to-objects linq-to-entities linq-to-sql

我有以下 SQL 查询

SELECT * FROM KDMS_dynamic vd

INNER JOIN KDMS_definition tblKDMS  ON tblKDMS.SystemID=vd.SystemID    
LEFT OUTER JOIN KDMS_typeid tblKDMSType ON tblKDMS.TypeId=tblKDMSType.TypeId            
INNER JOIN  KDMS_configuration tblKDMSConfig ON tblKDMS.SystemID=tblKDMSConfig.SystemID

    AND tblKDMSConfig.ConfigurationDate = (SELECT MAX(ConfigurationDate)
                                        FROM KDMS_configuration vc
                                        WHERE vc.SystemID=tblKDMSConfig.SystemID)
    AND vd.LastUpdated=(SELECT MAX(LastUpdated) FROM KDMS_dynamic vd 
                        WHERE vd.SystemID=tblKDMS.SystemID)  

        WHERE  

         DeletionDate IS NULL             
      AND LongDescription IS NOT NULL       
      AND tblKDMS.TypeId <> 1        
Run Code Online (Sandbox Code Playgroud)

由于我已尝试将其转换为 LINQ,但由于在内部联接中使用了 AND OPERATOR,我无法将其转换为 LINQ。

我不知道如何在 LINQ 、 JOIN 中使用 And 运算符

按照我尝试的 linq 代码。

IQueryable<getKDMS> query = (from VD in this._db.GetTable<KDMS_dynamic>()
                                        join TblKDMS in this._db.GetTable<KDMS_definition>() on VD.SystemID equals TblKDMS.SystemID
                                        join TblKDMSType in this._db.GetTable<KDMS_typeid>().DefaultIfEmpty() on TblKDMS.TypeID equals TblKDMSType.TypeID 
                                        join TblKDMSConfig in this._db.GetTable<KDMS_configuration>() on TblKDMS.SystemID equals TblKDMSConfig.SystemID

                                        &&  TblKDMSConfig.ConfigurationDate == (from TblKDMS_conf in this._db.GetTable<KDMS_configuration>()
                                                                                      where TblKDMS_conf.SystemID == TblKDMSConfig.SystemID
                                                                                      select TblKDMS_conf.ConfigurationDate).Max())
Run Code Online (Sandbox Code Playgroud)

正如我尝试使用 && 但它没有用....

Fos*_*erZ 5

它是这样完成的 on new{x.field1,x.field2} equals new{y.field1,y.field2}

var somedata = (from TblKDMS_conf in this._db.GetTable<KDMS_configuration>()
              where TblKDMS_conf.SystemID == TblKDMSConfig.SystemID select TblKDMS_conf.ConfigurationDate).Max();

Queryable<getKDMS> query = (from VD in this._db.GetTable<KDMS_dynamic>()
                                    join TblKDMS in this._db.GetTable<KDMS_definition>() on VD.SystemID equals TblKDMS.SystemID
                                    join TblKDMSType in this._db.GetTable<KDMS_typeid>().DefaultIfEmpty() on TblKDMS.TypeID equals TblKDMSType.TypeID 
                                    join TblKDMSConfig in this._db.GetTable<KDMS_configuration>() on new {TblKDMS.SystemID,TblKDMSConfig.ConfigurationDate} equals new{TblKDMSConfig.SystemID,somedata}
Run Code Online (Sandbox Code Playgroud)