Language: C#
Linq2Object group by query
1: public IResult GetResultTree() 2: { 3: return new WebServiceResult<CampaignSessionBeanClient, GetCampaignTreeResultCompletedEventArgs>(x => x.GetCampaignTreeResultAsync(GetCampaignFilter()), x => 4: { 5: var propsals = new ProposalMapper().MapMany(x.Result); 6: var Agencies = from agc in propsals 7: group agc by agc.Agency.OrgOrgRoleId into agcGroup 8: select new 9: { 10: OrgOrgRoleIdAgc = agcGroup.Key, 11: Advertisers = from adv in agcGroup 12: group adv by adv.Advertiser.OrgOrgRoleId into advGroup 13: select new 14: { 15: OrgOrgRoleIdAdv = advGroup.Key, 16: Products = from prd in advGroup 17: group prd by prd.Product.ProductId into prdGroup 18: select new 19: { 20: ProductId = prdGroup.Key, 21: Campaigns = prdGroup 22: } 23: } 24: }; 25: }); 26: }
Tags:
Description:
Query of the day: How to convert flat structures to hierarchical
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

