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!
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