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
Thanks again Mike. I'll just statically list them in that case.
Hi Richard,
Richard said:Is there a way to determine what sort of argument a particular UltraCalcFunction requires? As far as I see, the only properties exposed are descriptive information used in the FormulaBuilderDialog. I'd like to be able to determine whether a function can be applied to a numerical column or not e.g. STDEV would be listed, but ROUND, CONCATENATE etc. would not be.
No, there is no way to determine the data types of the parameters to a function. The CalcManager itself does not have a concept of this and does not enforce it.
Richard said:If there is no suitable way to determine whether a function can be applied to a numerical column, am I right in thinking that only the functions listed in the Statistical category would be valid in this scenario?
No, there's no way to tell from the functions themselves. I'm sure there are other functions outside of the statistical category that would work for numeric columns. The Engineering category, for example, has some functions that would work. So does Financial, Math, and probably others, as well.
EDIT to my last post - I've just noticed the SUM function would obviously be valid (and is not under the Statistical category), so scrap that second question...
Okay, so I've decided to scrap the idea of incorporating the FormulaBuilderDialog with LINQ. I'm now aiming to allow the user to select an Infragistics Function from the list, select the column(s) to apply the function to, and group using LINQ. This will not require use of the UltraGrid.
I have a coupld of questions regarding the functions that would work in this scenario, however:
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.