C# LINQ Filter a ThenInclude by specific value

56 Views Asked by At

I am sitting on a problem. I have a query (Anfragen) table. This query has header data. Then there is a position table (AnfragenPosNr). This contains all positions for the header request. Each position has an item, which is managed by n persons. Now I want to load a request and only (!) the associated positions that correspond to the operator/agent (The operator and items are in ViewAVMitarbeiterArtikel)).

I have displayed the navigation properties in yellow and green.

I hope the whole thing is understandable.

I tried to get the result via LINQ include. Unfortunately, I keep getting items that are not assigned to any agent. I do not want to receive these. Unfortunately it is not possible (I think) to filter a ThenInclude.

Anfragen
.Include(x => x.Nav_Positionen)
.ThenInclude(x => x.Nav_AVBearbeiter) // This need to be filtered, i guess.
.First(x => AnfrageID == V_PARAM_ID)
0

There are 0 best solutions below