PC Review


Reply
Thread Tools Rate Thread

DataColumn.Expression

 
 
Andrzej Kaczmarczyk
Guest
Posts: n/a
 
      17th Oct 2005
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


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      17th Oct 2005
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).

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

"Andrzej Kaczmarczyk" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Andrzej Kaczmarczyk
Guest
Posts: n/a
 
      17th Oct 2005
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/fu...s/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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
W.G. Ryan - MVP
Guest
Posts: n/a
 
      17th Oct 2005
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
"Andrzej Kaczmarczyk" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataColumn.Expression shark Microsoft C# .NET 3 17th May 2007 04:15 PM
DataColumn Expression Q Vai2000 Microsoft C# .NET 1 4th Mar 2005 02:00 PM
DataColumn.Expression Ray Microsoft ADO .NET 1 17th Nov 2004 10:17 AM
DataColumn Expression Joel Rumerman Microsoft Dot NET Framework Forms 10 11th Aug 2004 09:03 AM
DataColumn.Expression Rodrigo Microsoft ADO .NET 1 7th Oct 2003 07:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:10 PM.