I have a big question about the use of conditions in group joins using Dynamic Linq Query syntax.
I have the following code, which I am using to generate a left join code.
result = result.AsQueryable().GroupJoin(entitiesQuerySecundary.AsQueryable(), "REventID", "EventID", $"new(outer as p, inner as s)");
result = result.SelectMany("s.DefaultIfEmpty()", $"new({string.Join(", ", selectedPropertyNames)})").Distinct();
Here in the first result I create the group join with a single code making the comparison of the input and output parameter.
My question is there a way to use 2 conditions? for example REventID = EventID plus RStatus = StatusID.
I have a big question about the use of conditions in group joins using Dynamic Linq Query syntax.
I have the following code, which I am using to generate a left join code.
result = result.AsQueryable().GroupJoin(entitiesQuerySecundary.AsQueryable(), "REventID", "EventID", $"new(outer as p, inner as s)");
result = result.SelectMany("s.DefaultIfEmpty()", $"new({string.Join(", ", selectedPropertyNames)})").Distinct();
Here in the first result I create the group join with a single code making the comparison of the input and output parameter.
My question is there a way to use 2 conditions? for example REventID = EventID plus RStatus = StatusID.
Share Improve this question asked Nov 16, 2024 at 7:13 Sergio MarchantSergio Marchant 1 1 |1 Answer
Reset to default 0You are doing a group join of the result
table with entitiesQuerySecundary
and assigning it back to the result
, which will create a problem.
If you want to group join "table1" with "table2". You can try -
var result = table1.AsQueryable().GroupJoin(
table2.AsQueryable(),
"new (REventID, RStatus)",
"new (EventID, StatusID)",
"new (outer as table1, inner as table2)"
);
This should return rows from table1 and corresponding rows from table2 where both keys match.
new(REventID, RStatus), new(EventID, Status)
? – Gert Arnold Commented Nov 16, 2024 at 16:43