Home All Groups Group Topic Archive Search About

aggregation simple .net code

Author
16 Jan 2006 4:28 AM
Dave Johnson
greetings,



can any one show sample example of aggregation in any .net code vb.net
or C#



i guess it shouldnt be that hard but i searched a lot without finding
anything that explains the issue in code. please help!

Sharing makes All the Difference

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Author
16 Jan 2006 7:45 AM
Cor Ligthert [MVP]
Dave,

At least you will have to tell how you want to aggregate.

In it simplest form it is only looping through a collection of data and add
the fields that has to be aggregated.

Cor
Author
16 Jan 2006 11:45 AM
Dave Johnson
Greetings Cor,

i have 2 classes first one is an Order Class and the 2nd one is an
Booking Class. the order Object consists of one or more booking objects

would u try to show aggregation on this example or in any other example.
i just wanna see some code to get the idea right noneed even to comment
it :)

thnx

Sharing makes All the Difference

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Author
16 Jan 2006 12:09 PM
Cor Ligthert [MVP]
Dave,

Assuming that your Order has a collection of bookings, where in is a value

\\\
dim totalvalue as integer = 0
dim totalpersons as integer = 0
For each bk as booking in MyOrder.BookingCollection
totalvalue = bk.WhateverValue
totalamount = bk.TotalPersons
next
///

I hope this helps,

Cor
Author
16 Jan 2006 12:17 PM
Dave Johnson
thanks cor for your help, but just to make sure i wanna say it this way.

my making a collection of objects from one class into the another class,
i am making an aggregation relationship between the two classes


is this 100% right or am i missing somthing.

thanks again

Sharing makes All the Difference

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Author
16 Jan 2006 3:00 PM
Cor Ligthert [MVP]
Dave,

I showed it you where the bookings are a collection in the order. It can of
course as well with by instance two datatables where the order is the Parent
from the booking or in other words the booking is one of the child of the
Order.

The code stays than almost the same, however you are iterating through the
childs.

To show you one link,

http://msdn2.microsoft.com/en-us/library/system.data.datarelation.childtable.aspx

I hope this helps,

Cor

Show quoteHide quote
"Dave Johnson" <esharpco***@gmail.com> schreef in bericht
news:ON81TbpGGHA.3700@TK2MSFTNGP15.phx.gbl...
> thanks cor for your help, but just to make sure i wanna say it this way.
>
> my making a collection of objects from one class into the another class,
> i am making an aggregation relationship between the two classes
>
>
> is this 100% right or am i missing somthing.
>
> thanks again
>
> Sharing makes All the Difference
>
> --
> Sent via .NET Newsgroups
> http://www.dotnetnewsgroups.com