I’m using studio 20.4 and want to do ‘group by sum’ operation on a DataTable like belows.
To do this job, I wrote a ‘Invoke code’ running LINQ Query and CopyToDataTable operation.
However, my ‘Invoke code’ throws runtime exception. (Please refer to the attachment)
Could anyone please figure out this issue? Thanks in advance!
@yhkim7
you can also Try using linq like
DtRecrod.AsEnumerable().GroupBy(Function(row) row.Item(“BizCode”)).Select(Function(group) New With {.BizCode= group.Key, .Price= group.Sum(Function( r ) Double.Parse(r.Item(“Price”).ToString()))})
Thanks for your correction.
Yes, you’re right. I missed that instantiation part! because I get used to use ‘Build Data Table’ Activity at which I can simply defined table and then set columns and put data.
I also know the ‘Method Syntax’ in LINQ, but the point is that I wanted to get the result into DataTable using CopyToDataTable not into IEnumerable(Of Object) with which I can’t put into DataTable easily.
Thanks for you reply.