Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Task("LinqObj87");
- var A = File.ReadAllLines(GetString(), Encoding.Default);
- var D = File.ReadAllLines(GetString(), Encoding.Default);
- var E = File.ReadAllLines(GetString(), Encoding.Default);
- var AA = A.Select(e =>
- {
- var s = e.Split(' ');
- return new
- {
- year_b = s[0],
- street = s[1],
- code_potr = s[2]
- };
- }).OrderBy(x=>x.street);
- var DD = D.Select(e =>
- {
- var s = e.Split(' ');
- return new
- {
- art_good = s[0],
- shop = s[1],
- price_good = int.Parse(s[2])
- };
- });
- var EE = E.Select(e =>
- {
- var s = e.Split(' ');
- return new
- {
- shop = s[0],
- code_potr = s[1],
- art_good = s[2]
- };
- });
- var res= AA.Join(EE.GroupJoin(DD,q=>q.shop+q.art_good,w=>w.shop+w.art_good,(q,ww)=>new
- {
- code_potr=q.code_potr,
- shop=q.shop,
- s=ww.Select(x=>x.price_good).Sum()
- }), x => x.code_potr, y => y.code_potr,(x,y)=>$"{x.street} {y.shop} {y.s}").Distinct();
- var rr = AA.Join(EE, x => x.code_potr, y => y.code_potr, (x, y) => new
- {
- str=x.street,
- sh=y.shop,
- art=y.art_good
- });
- var pp = rr.GroupJoin(DD, q => q.sh + q.art, w => w.shop + w.art_good, (q, ww) => new
- {
- street=q.str,
- shop=q.sh,
- s=ww.Where(x=>x.shop==q.sh && x.art_good==q.art).Select(x=>x.price_good).Sum()
- }).Distinct();
- var kk = pp.GroupBy(x => x.street +" "+x.shop, (key, value) => new
- {
- var s = key.Split(' '),
- street=s[0],
- //street =key,
- sum=value.Where(x=>x.street+x.shop==key).Select(g=>g.s).Sum(),
- streetr=value.Where(x => x.street + " " + x.shop == key).Select(g=>g.street),
- shopr= value.Where(x => x.street + " " + x.shop == key).Select(g => g.shop)
- }).Select(x=>x.streetr+" "+x.shopr+" "+x.sum).Show();
Add Comment
Please, Sign In to add comment