Hi All,
I've been very impressed so far with LINQ, particularly when it comes to grouping and apply aggregate functions to data. I've also been impressed with Infragistics' library of functions and the FormulaBuilderDialog.
Ideally, I'd like to combine the two... to group rows in a DataTable using LINQ - applying aggregate functions that could be initially specified in the syntax of the Infragistics' functions e.g. 'stdev([PRICE]) / average([PRICE])'.
I've been looking into the use of LINQ's 'Aggregate' keyword to use a custom function, but wondered if there's anyway to incorporate the Infragistics functions with this. Does anyone have any ideas?
I can see a way of interpreting the syntax myself but this would still involve me having to write (or find) source-code for the functions supported in the Infragistics Formula Builder e.g. standard deviation.
So my questions are:
Any information - be it little or large - will be greatly appreciated. =)
Cheers,
Richard
Hi Richard,
I'm afraid I'm not entirely clear what you are trying to do. You want to apply a formula to... what exactly?The results of a LINQ Query?
I think the easiest thing to do would be to bind the data you get back from your LINQ query to a WinGrid and then apply formulas to the grid.
Hi Mike,
Thanks for the quick response. Apologies, what I would like to do is take in a DataTable, apply a grouping and apply a formula to it in that grouping, effectively getting a DataTable consisting of rows that are simply the Group labels with the aggregate results for that group e.g.
Blue, 200, 131
Green, 258, 124
where, for example, 200 is the standard deviation of the price of all the 'Blue' entries, 131 is the mean average of the price of all the 'Blue' entries etc.
I'm looking to do this BEFORE binding it to the grid, ideally, but I think you maybe right in that the easiest thing would be to group the data, bind, then apply some extra columns for the formula. Is that what you're suggesting?
I've just been having a play around with the CalcFunction classes themselves e.g. UltraCalcFunctionSum and encapsulating the PerformEvaluation method of each to give a function that can be used with LINQ, which is working nicely! But I'd still have to parse the formula string so that more complicated formulas could be processed i.e. it currently only works with one function e.g. SUM or STDEV.