c# - LINQ group by and return all results -


i have troubles finding solution this. know had lot of topics here, none of (which found) works me. question, have this:

   list<products> testlist = new list<products>(); 

this list have 2 fields, price , stock. want group stocks condition still show results. i'm grouping values this:

  var stocks=testlist.where(item=> item.stock== "stocksfr1:").groupby(item=> item.stock); 

this works fine. want iterate through results, , i'm failing. have tried join, don't know on attribute can join these values. anybody? thanks!

update: (example of input list:)

    stock:        price:     stocksfr1:    14.55     stocksfr1:    3.4     stocksfrf:    1.1     stocksfra:    13.3 

and group, want have output:

    stock:        price:     stocksfr1:    14.55, 3.4     stocksfrf:    1.1     stocksfra:    13.3 

okay, disregarding of have , looking @ example data, seems want this:

var grouped = testlist.groupby(item=> item.stock); var eachstock = grouped.select(c => string.join(" ", c.key, string.join(", ", c.select(x => x.price))));  console.write(string.join(environment.newline, eachstock)); 

that have written, within reason. doubt want string manipulation stuff, put in there can see results before need where clause again.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -