question

MarkusFreitag-0088 avatar image
0 Votes"
MarkusFreitag-0088 asked ·

LinQ, GroupBy, C#

Hello,
I have a Master Detail relationship.

Master 1:n Detail
1:n Detail (List)

Via LinQ I would like to group it.
That works too. But I can't reach the ResultView. See the green marker.
What should the query be called?

Thanks in advance for tipps and samples.

The code

    var qryPanelIndex = CurrentPanel.MainList[0].ListDetailBoards.GroupBy(info => info.PanelIndex)
                     .Select(group => new
                     {
                         PanelIndex = group.Key,
                         CountOccurrences = group.Count()
                     })
                     .OrderBy(x => x.PanelIndex).ToList();
    
             var qryPanelIndex2 = CurrentPanel.MainList[0].ListDetailBoards.GroupBy(info => info.PanelIndex).ToList();
    
             foreach(var item in qryPanelIndex2)
             {




windows-wpfdotnet-adonet
-at-a-1.png (63.8 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DanielZhang-MSFT avatar image
1 Vote"
DanielZhang-MSFT answered ·

Hi Markus Freitag,
>>I can't reach the ResultView
According to my understanding, do you want to reach the value of ListPosition in resultView of qryPanelIndex.
If so, you can add this line in the select statement.

 .Select(group => new
                      {
                          PanelIndex = group.Key,
                          CountOccurrences = group.Count(),
                           ListPosition=group.ToArray()
                      })

If not, please explain in detail.
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

That is it, works well! Thanks a lot for your help.

0 Votes 0 ·