linq - Group and sum list (vb.net) -


i've got list of objects

    class bundledtellingen         property ttimestamp string         property tvalue double     end class 

now trying group list ttimestamp , sum tvalue. searching similar questions clear best way go using linq. i've put together:

    dim query = bundledlist.groupby( _     function(telling) telling.ttimestamp, _     function(telling) telling.ttimestamp, _     function(ts, values) new _         {.key = ts, _         .sum = values.sum()} _     )      using writer streamwriter = new streamwriter("c:\test.txt")         each result in query             writer.writeline(result.key & " " & result.sum)         next     end using 

as far can tell looking @ examples @ http://msdn.microsoft.com/en-us/library/bb534493.aspx#y0 should work, though following exception: "overload resolution failed because no accessible 'sum' accepts number of arguments."

you've specified 1 unnecessary parameter groupby call. thy one:

dim query = bundledlist.groupby( _                 function(telling) telling.ttimestamp, _                 function(ts, values) new _                     {.key = ts, _                     .sum = values.sum()} _                 ) 

the first 1 key selector, second result selector.

your call 3 parameters has additional value selector, you're selecting function(telling) telling.ttimestamp twice - once key , once value. that's why sum didn't work: tried call sum on telling.ttimestamp.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -