Data in Linq query not in join is not in output to json only those that are related in 2 classes are showing up

后端 未结 1 1588
轮回少年
轮回少年 2021-01-27 09:57

The basis of this question is from this question:

Combine 2 classes with adding data and 1 table has a colllection list of the other table and wanting to use linq to dis

1条回答
  •  囚心锁ツ
    2021-01-27 10:30

    I think the linked question was not answered correctly.

    Looks like all you need is a simple Group Join:

    var query = 
        from d in reportData
        join r in reportDefinition on d.ReportGroupId equals r.ReportGroupId into items
        select new
        {
            d.ReportGroupName,
            items = items.ToList(),
            d.ReportGroupId
        };
    

    0 讨论(0)
提交回复
热议问题