2
I have to perform a consultation where I need to do 4 INNER JOIN
and still use WHERE
in various fields.
What is most advisable?
- Conduct the consultation in this way?
using (DbContexto db = new DbContexto()) { var query = (from t1 in db.tabela1 join t2 in db.tabela2 on t1.id equals t2.fk_t1 join t3 in db.tabela3 on t1.idt3 equals t3.fk_t1 where (t1.v1 = 1) && (t2.v2 = 2) && (t3.v3 = 3) select t1 ); }
- Or that?
List listaTabela1 = new List(); List listaTabela2 = new List(); List listaTabela3 = new List(); using (DbContexto db = new DbContexto()) { listaTabela1 = (from t1 in db.tabela1 select t1).ToList(); listaTabela2 = (from t2 in db.tabela2 select t2).ToList(); listaTabela3 = (from t3 in db.tabela3 select t3).ToList(); var query = (from t1 in listaTabela1 join t2 in listaTabela2 on t1.id equals t2.fk_t1 join t3 in listaTabela3 on t1.idt3 equals t3.fk_t1 where (t1.v1 = 1) && (t2.v2 = 2) && (t3.v3 = 3) select t1 ); }
Please avoid long discussions in the comments; your talk was moved to the chat
– Maniero