我該怎麼做query
使用LINQ and LAMBDA
?Multiple Select and Join with LINQ and Lambda
QUERY
Select san_negocio.imovel_id
,san_negocio.negocio_id
,san_imovel.credenciada_id
,san_proposta.proposta_id
,san_proposta.credenciada_id
from san_negocio
join san_proposta
on san_negocio.imovel_id = san_proposta.imovel_id
join san_imovel
on san_negocio.imovel_id = san_imovel.imovel_id
where san_negocio.credenciadacaptadora_id is null
and san_negocio.credenciadavendedora_id is null
and san_proposta.statusproposta_id = 2
我已經試過:
var objetos = db.San_Negocio.Join(db.San_Proposta, a => a.Imovel_Id, b => b.Imovel_Id, (a, b) => new { San_Negocio = a, San_Proposta = b })
.Join(db.San_Imovel, a => a.San_Negocio.Imovel_Id, c => c.Imovel_Id, (a, c) => new { San_Negocio = a, San_Imovel = c })
.Where(a => a.San_Negocio.San_Negocio.CredenciadaCaptadora_Id == null && a.San_Negocio.San_Negocio.CredenciadaVendedora_Id == null)
.Select(a => new { a.San_Negocio.San_Negocio.Negocio_Id,
a.San_Negocio.San_Negocio.Imovel_Id,
a.San_Imovel.Credenciada_Id });
我懷疑是我Select
。我怎麼打電話給我的San_Proposta
表?
爲什麼需要它要用lambda來完成?該版本看起來絕對不好理解。 – Arran
可以沒有拉姆達。這是因爲我想更好地理解lambda如何與之合作。 –
我認爲這可能會更好,如果你第一次閱讀一些關於linq code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b#nested的示例,然後決定你想使用什麼方法 –