Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

296
Visualizações
Is there a way to use a memberexpression inside a join/linq? reflection

I'm trying to do a dynamic join for entity framework and having a few problems. I'm storing in a dictionary my lambda which is what I want to be used in the generic join.

So for example I would insert into the dictionary x => x.table1.table2.myid

I'm then trying to use that path which works in a join (when not dynamic)

Normally expression1 & 2 would be the same(int) as the value passed into the dictionary.

myquery.Join(
            table,
            t => expression1, d=> expression2,
            (t, d) => new { t, d});

I feel like i'm a dead end and I cant find anything at all about doing a dynamic join like this using a navigation property. I was hoping memberexpression would be what I need but it seems not. I've tried various combinations of expressions.lambda and other expression functions to no avail either. I'm hoping someone can give me some direction here!

It does compile with the memberexpression but thats because left and right side of the join are the same type so it allows it

Is this even possible?

Further research I think I need to do something more with

return Expression.Lambda<Func<T, bool>>(body, item);

However if I do this the join won't work as T will be two different items. There must be a simple way to get two navigation properties dynamically both ints!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It is not very clear to me what you have in mind, but if you need two different items as input of your Func you can take a look at this: https://docs.microsoft.com/en-us/dotnet/api/system.func-3?view=netcore-3.1

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda