2

在 sqlcommand 我有这个:

SELECT * 
FROM cliente c
    LEFT JOIN abono a on
        c.idcliente = a.idcliente
        and (a.estatus = 1 or a.estatus = null)
    LEFT JOIN usuario u on
        a.creadopor = u.idusuario
WHERE c.estatus = 1

我们知道这与此不同:

SELECT * 
FROM cliente c
     LEFT JOIN abono a on
         c.idcliente = a.idcliente
     LEFT JOIN usuario u on
         a.creadopor = u.idusuario
WHERE c.estatus=1
      and (a.estatus = 1 or a.estatus = null)

如何在实体框架中进行第一次查询?

实体框架中的第二个查询是

from c in Conexion.conexion.conect.cliente
join a in Conexion.conexion.conect.abono
on c.idcliente equals a.idcliente into alj
from a in alj.DefaultIfEmpty()
join u in Conexion.conexion.conect.usuario
on a.creadopor equals u.idusuario into ulj
from u in ulj.DefaultIfEmpty()
where c.estatus == 1
&& (a.estatus == 1 || a.estatus == null)

但我无法获得第一个查询

4

1 回答 1

0

这可以解决问题:

from c in Conexion.conexion.conect.cliente
join a in Conexion.conexion.conect.abono.Where(x.estatus == 1 || x.estatus == null)
on c.idcliente equals a.idcliente into alj
from a in alj.DefaultIfEmpty()
join u in Conexion.conexion.conect.usuario
on a.creadopor equals u.idusuario into ulj
from u in ulj.DefaultIfEmpty()
where c.estatus == 1
于 2013-04-25T17:11:09.753 回答