如何将sql查询转换为不等于的linq?

hvvq6cgz  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(397)

这是我的sql查询;

select * from kirala inner join saatler on Kirala.Tarih = '2020-05-31' and Kirala.Onay = 'true' and Kirala.SaatID != saatler.ID

我是这样的;

var kirala2 = from t1 in _context.Kirala
                          join t2 in _context.Saatler on t1.SaatID equals t2.ID 
                          where t1.Tarih == "2020-05-31" && t1.Onay == true && t1.YatID == id
                          select new Saatler { Saat = t2.Saat, ID = t2.ID };

但这对我没用因为 t1.SaatID equals t2.ID 我不能用不等于我还能做什么?

oaxa6hgo

oaxa6hgo1#

只需将连接中的所有条件移动到

var kirala2 = from t1 in _context.Kirala
              from t2 in _context.Saatler 
              where t1.SaatID != t2.ID 
                    && t1.Tarih == "2020-05-31" 
                    && t1.Onay == true 
                    && t1.YatID == id
              select new Saatler { Saat = t2.Saat, ID = t2.ID };

相关问题