I stucked to write a nested query with Select or SelectMany.
Let’s take the traditional nested list that:
Sheet has Title fields
SheetDetail has Employee fields
Each Sheet has multiple SheetDetails as a master-detail manner.
I would like to make the result as below.
From below data…
Sheet - SheetDetail
"A Sheet"-{"jane","herry","tom"}
"B Sheet"-{"kane","brown","jane"}
"C Sheet"-{"annie","ralph"}
To the result as below that has only ‘jane’ but maintain same master-detail structure.
Sheet - SheetDetail
"A Sheet"-{"jane"}
"B Sheet"-{"jane"}
I tried
sheet.SelectMany(s => s.SheetDetails.Where(d => d.Description.Contains("jane")));
but as we can imagine, it gives wrong result.
How can I make it? please help-
You can use
Anyto check: