Home All Groups Group Topic Archive Search About

Calculated Fields in Strongly Typed DataSets?

Author
10 Jan 2006 11:48 PM
Tore
We have an XSD schema/object graph that for the most part reflects our
database.  I'm running into an issue where this granularity doesn't always
match the need for using data from multiple datatables.  For example, I have
a master datatable with several detail datatables, and I would like to
create (declare if I can) a "composite" containing column values from the
master, as well as columns from other datatables along with aggregate values
of data in yet other datatables.

In reality, this resulting data will be displayed in a grid (one column will
be updatable) and consurrently bound to other controls.

If I was writing stored procedures and handcoding every operation, this
would be quite straight forward, but I am trying to work with the object
graph/schema approach.

Is there a way to do this in the schema itself?

What would be the best way to achieve this?  Would I need to create derived
DataViews and programmatically add expression columns?  And would I have to
implement the "external" accesses in event handlers?

TIA,
Tore.

Author
11 Jan 2006 7:35 AM
Miha Markic [MVP C#]
Though there is calculated field support built in DataTable (through
DataColumn.Expression) I would recommend to:
- add necessary column(s) do DataTable
- handle updating yourself (using RowChanged/ColumnChanged) events

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

Show quote
"Tore" <tbostrup at agfirst> wrote in message
news:OfUaSBkFGHA.3036@tk2msftngp13.phx.gbl...
> We have an XSD schema/object graph that for the most part reflects our
> database.  I'm running into an issue where this granularity doesn't always
> match the need for using data from multiple datatables.  For example, I
> have
> a master datatable with several detail datatables, and I would like to
> create (declare if I can) a "composite" containing column values from the
> master, as well as columns from other datatables along with aggregate
> values
> of data in yet other datatables.
>
> In reality, this resulting data will be displayed in a grid (one column
> will
> be updatable) and consurrently bound to other controls.
>
> If I was writing stored procedures and handcoding every operation, this
> would be quite straight forward, but I am trying to work with the object
> graph/schema approach.
>
> Is there a way to do this in the schema itself?
>
> What would be the best way to achieve this?  Would I need to create
> derived
> DataViews and programmatically add expression columns?  And would I have
> to
> implement the "external" accesses in event handlers?
>
> TIA,
> Tore.
>
>
Author
11 Jan 2006 5:22 PM
Tore
I am aware of the Expression property, but I was trying to implement
something (declaratively) at the XSD schema level.  Is this possible and if
so, how?

If not, I suppose my closest approach would be to add the columns to the
schema, and make them Expression columns in code before filling the dataset.

Why do you recommend against using the DataColumn.Expression approach?

Thanks,
Tore.

Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:uT8BUGoFGHA.344@TK2MSFTNGP11.phx.gbl...
> Though there is calculated field support built in DataTable (through
> DataColumn.Expression) I would recommend to:
> - add necessary column(s) do DataTable
> - handle updating yourself (using RowChanged/ColumnChanged) events
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "Tore" <tbostrup at agfirst> wrote in message
> news:OfUaSBkFGHA.3036@tk2msftngp13.phx.gbl...
> > We have an XSD schema/object graph that for the most part reflects our
> > database.  I'm running into an issue where this granularity doesn't
always
> > match the need for using data from multiple datatables.  For example, I
> > have
> > a master datatable with several detail datatables, and I would like to
> > create (declare if I can) a "composite" containing column values from
the
> > master, as well as columns from other datatables along with aggregate
> > values
> > of data in yet other datatables.
> >
> > In reality, this resulting data will be displayed in a grid (one column
> > will
> > be updatable) and consurrently bound to other controls.
> >
> > If I was writing stored procedures and handcoding every operation, this
> > would be quite straight forward, but I am trying to work with the object
> > graph/schema approach.
> >
> > Is there a way to do this in the schema itself?
> >
> > What would be the best way to achieve this?  Would I need to create
> > derived
> > DataViews and programmatically add expression columns?  And would I have
> > to
> > implement the "external" accesses in event handlers?
> >
> > TIA,
> > Tore.
> >
> >
>
>
Author
11 Jan 2006 6:41 PM
Tore
Nevermind - I found it.

<xs:element name="ComputedData" type="xs:int" minOccurs="0" nillable="0"
msprop:nullValue="_null"
msdata:Expression="Count(Related.RelatedPKColumn)" />


Tore.

Show quote
"Tore" <tbostrup at agfirst> wrote in message
news:%23toZbOtFGHA.1088@tk2msftngp13.phx.gbl...
> I am aware of the Expression property, but I was trying to implement
> something (declaratively) at the XSD schema level.  Is this possible and
if
> so, how?
>
> If not, I suppose my closest approach would be to add the columns to the
> schema, and make them Expression columns in code before filling the
dataset.
>
> Why do you recommend against using the DataColumn.Expression approach?
>
> Thanks,
> Tore.
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:uT8BUGoFGHA.344@TK2MSFTNGP11.phx.gbl...
> > Though there is calculated field support built in DataTable (through
> > DataColumn.Expression) I would recommend to:
> > - add necessary column(s) do DataTable
> > - handle updating yourself (using RowChanged/ColumnChanged) events
> >
> > --
> > Miha Markic [MVP C#]
> > RightHand .NET consulting & development www.rthand.com
> > Blog: http://cs.rthand.com/blogs/blog_with_righthand/
> >
> > "Tore" <tbostrup at agfirst> wrote in message
> > news:OfUaSBkFGHA.3036@tk2msftngp13.phx.gbl...
> > > We have an XSD schema/object graph that for the most part reflects our
> > > database.  I'm running into an issue where this granularity doesn't
> always
> > > match the need for using data from multiple datatables.  For example,
I
> > > have
> > > a master datatable with several detail datatables, and I would like to
> > > create (declare if I can) a "composite" containing column values from
> the
> > > master, as well as columns from other datatables along with aggregate
> > > values
> > > of data in yet other datatables.
> > >
> > > In reality, this resulting data will be displayed in a grid (one
column
> > > will
> > > be updatable) and consurrently bound to other controls.
> > >
> > > If I was writing stored procedures and handcoding every operation,
this
> > > would be quite straight forward, but I am trying to work with the
object
> > > graph/schema approach.
> > >
> > > Is there a way to do this in the schema itself?
> > >
> > > What would be the best way to achieve this?  Would I need to create
> > > derived
> > > DataViews and programmatically add expression columns?  And would I
have
> > > to
> > > implement the "external" accesses in event handlers?
> > >
> > > TIA,
> > > Tore.
> > >
> > >
> >
> >
>
>
Author
11 Jan 2006 6:41 PM
Tore
Nevermind - I found it.

<xs:element name="ComputedData" type="xs:int" minOccurs="0" nillable="0"
msprop:nullValue="_null"
msdata:Expression="Count(Related.RelatedPKColumn)" />


Tore.

Show quote
"Tore" <tbostrup at agfirst> wrote in message
news:%23toZbOtFGHA.1088@tk2msftngp13.phx.gbl...
> I am aware of the Expression property, but I was trying to implement
> something (declaratively) at the XSD schema level.  Is this possible and
if
> so, how?
>
> If not, I suppose my closest approach would be to add the columns to the
> schema, and make them Expression columns in code before filling the
dataset.
>
> Why do you recommend against using the DataColumn.Expression approach?
>
> Thanks,
> Tore.
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:uT8BUGoFGHA.344@TK2MSFTNGP11.phx.gbl...
> > Though there is calculated field support built in DataTable (through
> > DataColumn.Expression) I would recommend to:
> > - add necessary column(s) do DataTable
> > - handle updating yourself (using RowChanged/ColumnChanged) events
> >
> > --
> > Miha Markic [MVP C#]
> > RightHand .NET consulting & development www.rthand.com
> > Blog: http://cs.rthand.com/blogs/blog_with_righthand/
> >
> > "Tore" <tbostrup at agfirst> wrote in message
> > news:OfUaSBkFGHA.3036@tk2msftngp13.phx.gbl...
> > > We have an XSD schema/object graph that for the most part reflects our
> > > database.  I'm running into an issue where this granularity doesn't
> always
> > > match the need for using data from multiple datatables.  For example,
I
> > > have
> > > a master datatable with several detail datatables, and I would like to
> > > create (declare if I can) a "composite" containing column values from
> the
> > > master, as well as columns from other datatables along with aggregate
> > > values
> > > of data in yet other datatables.
> > >
> > > In reality, this resulting data will be displayed in a grid (one
column
> > > will
> > > be updatable) and consurrently bound to other controls.
> > >
> > > If I was writing stored procedures and handcoding every operation,
this
> > > would be quite straight forward, but I am trying to work with the
object
> > > graph/schema approach.
> > >
> > > Is there a way to do this in the schema itself?
> > >
> > > What would be the best way to achieve this?  Would I need to create
> > > derived
> > > DataViews and programmatically add expression columns?  And would I
have
> > > to
> > > implement the "external" accesses in event handlers?
> > >
> > > TIA,
> > > Tore.
> > >
> > >
> >
> >
>
>

AddThis Social Bookmark Button