实体框架多列
本文关键字:框架 实体 | 更新日期: 2023-09-27 18:10:48
在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)
但是我无法得到第一个查询
效果很好:
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