using System.Collections.Generic;
using System.Collections;
public static void Main()
List<ReportDefinition> reportDefinition = new List<ReportDefinition>();
reportDefinition.Add(new ReportDefinition() {Id = 5, ReportGroupNameDef = "Web Usuage", SortOrder = 1, ReportGroupId = 1, Type = 2});
reportDefinition.Add(new ReportDefinition() {Id = 6, ReportGroupNameDef = "Web 2", SortOrder = 1, ReportGroupId = 1, Type = 2});
reportDefinition.Add(new ReportDefinition() {Id = 7, ReportGroupNameDef = "Web 3", SortOrder = 1, ReportGroupId = 1, Type = 2});
reportDefinition.Add(new ReportDefinition() {Id = 8, ReportGroupNameDef = "Compliance Report", SortOrder = 1, ReportGroupId = 2, Type = 2});
List<CustomReportDefinition> customReportDefinition = new List<CustomReportDefinition>();
customReportDefinition.Add(new CustomReportDefinition() {Id = 5, ReportGroupNameDef = "custom 1", SortOrder = 1, ReportGroupId = 1, Type = 3});
customReportDefinition.Add(new CustomReportDefinition() {Id = 6, ReportGroupNameDef = "custom 2", SortOrder = 2, ReportGroupId = 1, Type = 3});
customReportDefinition.Add(new CustomReportDefinition() {Id = 7, ReportGroupNameDef = "custom 3", SortOrder = 1, ReportGroupId = 2, Type = 3});
customReportDefinition.Add(new CustomReportDefinition() {Id = 8, ReportGroupNameDef = "custom 4", SortOrder = 2, ReportGroupId = 2, Type = 3});
List<ReportData> reportData = new List<ReportData>();
reportData.Add(new ReportData() {ReportGroupId = 1, ReportGroupName = "Standard Report", SortOrder = 1, Type = 1});
reportData.Add(new ReportData() {ReportGroupId = 2, ReportGroupName = "Custom Report", SortOrder = 2, Type = 1});
reportData.Add(new ReportData() {ReportGroupId = 3, ReportGroupName = "Straggler", SortOrder = 3, Type = 1});
var query = from d in reportData
join r in reportDefinition on d.ReportGroupId equals r.ReportGroupId into items
join cr in customReportDefinition on d.ReportGroupId equals cr.ReportGroupId into customItems
items = items.Select(r => new
r.Id, r.ReportGroupNameDef, r.SortOrder, r.ReportGroupId, r.Type
}).Concat(customItems.Select(cr => new
cr.Id, cr.ReportGroupNameDef, cr.SortOrder, cr.ReportGroupId, cr.Type
string output = JsonConvert.SerializeObject(query);
public class AllReportDefinitions
public List<ReportDefinition> items {get; set;}
public List<CustomReportDefinition> moreitems {get; set;}
public List<AllReportDefinitions> items {get; set;}
public int ReportGroupId { get; set; }
public string ReportGroupName { get; set; }
public int SortOrder { get; set; }
public int Type { get; set; }
public class ReportDefinition
public int Id { get; set; }
public string ReportGroupNameDef { get; set; }
public int SortOrder { get; set; }
public int ReportGroupId { get; set; }
public int Type { get; set; }
public class CustomReportDefinition
public int Id { get; set; }
public string ReportGroupNameDef { get; set; }
public int SortOrder { get; set; }
public int ReportGroupId { get; set; }
public int Type { get; set; }