DataColumn.Expression

  • Thread starter Thread starter Andrzej Kaczmarczyk
  • Start date Start date
A

Andrzej Kaczmarczyk

Hi

is it possible to create and add new functions to be parsed by expressions?

I have the following situation.
master table - containing entities (cars, buildings you name it)
detail table - a parameter describing this entity (sometimes integer,
sometimes string)

I want to create a grid displaying master table sided by computed columns,
with values dependant on the detail table. Had it been invoices and
invoicelines I'd use
"Sum(Child(fk_invoice_invoiceline).invoice_line_value)"

but if they are string values the sum is not an option, I need two more
functions to complete.

First(child_table_rows) given some sort criteria I want to get the first of
the detail rows and put the value in computed field

Concatenations(child_table_rows) given some definable separator I want a
string values to be concatenated and returned.

How to do this?

thx
CUIN Kaczy
 
Hi Andrek,

No, but you could simulate expression by implementing DataTable events such
as ColumnChanged, calculate your value and insert it into the proper cell.
Before inserting the value check for the current RowState and if it is
Unchanged then call DataRow.AcceptChanges after the value insertion to mark
row as unchanged (if desired).
 
Hi
No, but you could simulate expression by implementing DataTable events
such as ColumnChanged, calculate your value and insert it into the proper
cell.
Before inserting the value check for the current RowState and if it is
Unchanged then call DataRow.AcceptChanges after the value insertion to
mark row as unchanged (if desired).
:( so far everything in .NET was a class of something, it strikes me
surprising that the DataColumn expression is a simple string. It has to be
parsed somewhere, are you sure there is this mechanism is not extendable in
a way that would allow writing my own functions?

I'd rather avoid setting up another event if the computation mechanism is
already in place.
And I've seen that it is pretty fast.

btw. I've managed to simulate the First() function with Min(), but without
sorting/filtering it's use is quite limited.

btw again. It seems the the problem is beeing address by the C# 3.0 and LINQ
http://msdn.microsoft.com/vcsharp/future/linqsamples/default.aspx

CUIN Kaczy
--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Andrzej Kaczmarczyk said:
Hi

is it possible to create and add new functions to be parsed by
expressions?

I have the following situation.
master table - containing entities (cars, buildings you name it)
detail table - a parameter describing this entity (sometimes integer,
sometimes string)

I want to create a grid displaying master table sided by computed
columns, with values dependant on the detail table. Had it been invoices
and invoicelines I'd use
"Sum(Child(fk_invoice_invoiceline).invoice_line_value)"

but if they are string values the sum is not an option, I need two more
functions to complete.

First(child_table_rows) given some sort criteria I want to get the first
of the detail rows and put the value in computed field

Concatenations(child_table_rows) given some definable separator I want a
string values to be concatenated and returned.

How to do this?

thx
CUIN Kaczy
 
Andrzej - I may not understand you correctly, but one thing that may be an
option is creating a subclassed datatable that has the functions you need in
them. So you could write your own First method and Concatenations method
respectively. You can then call these directly. I've done this before when
i needed some more advanced statistical functions that weren't supported by
Compute. then instead of calling Compute - you can call (for instance in my
scenario) DataTableName.ThreeSigmaLimits which would return an array of
values corresponding to the upper and lower bounds of a three sigma control
chart. I was passing in a DataColumn which is what it used to compute. As
such, you can call each method just as you are calling Compute now.

However I have a feeling that I may not have understood your scenario
exactly, if so, please let me know and I'll try to address it.

Thanks,

Bill
 
Back
Top