Join with lambda Expression only

Asked

Viewed 1,104 times

1

With LINQ no problem. Now, how do I make a join with two or more tables? Below the attempt of the join that I couldn’t go through with. Two tables(T_Acao and T_ProximaAcao). Field in join is the IDAcao

var resultadoAcao = (db.T_Acao
                                    .Where(a => a.IDAcao == 7)
                                    .Join(db.T_ProximaAcao, p => p.IDAcao )
                                );

How do I finish this Join?

1 answer

2


Solved. A colleague passed me:

var resultadoAcao = (db.T_Acao.Join(
                                    db.T_ProximaAcao,
                                    t1 => t1.IDAcao,
                                    t2 => t2.IDAcao,
                                    (t1, t2) => new { t1, t2})
                                    .Where( a => a.t1.IDAcao == 7)
                                     .Select(i => new {acao = i.t1.Acao, proximaacao = i.t2.ProximaAcao})
                                ).ToList();
  • I ask you to please accept your answer so that the question no longer appears as "unanswered". Thank you!

  • 1

    I know, only the SOPT only releases to accept my answer after two days.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.