473,474 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MyClassCollection = MyDataTable

Hi,

I want a fast way to use assign a tha values in a DataTable to a
collection/Array/List of Classes. Each record in my DataTable should be new
Class, and tha Class would have property's for each Field in the DataTable.

Is something like this possible? Or how should I do something like this?

A more practical exemple:
I have a Class clsCustomer, which contains many orders: so a
Collection/Array/List of the clsOrder.
So with the CustomerID, I want to have the whole Collection/Array/List of
the clsOrder of this Customer...

Thanks a lot in advance,

Pieter
Aug 8 '05 #1
7 1222
Take a look into CollectionBase class
public class FeederCollection : CollectionBase
Regards
Jignesh Desai - MVP
Blogs @ http://dotnetjini.jigneshdesai.com/Blogs/default.aspx
..NET Training Programs : http://dotnetjini.jigneshdesai.com/Training.aspx
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Hi,

I want a fast way to use assign a tha values in a DataTable to a
collection/Array/List of Classes. Each record in my DataTable should be new Class, and tha Class would have property's for each Field in the DataTable.
Is something like this possible? Or how should I do something like this?

A more practical exemple:
I have a Class clsCustomer, which contains many orders: so a
Collection/Array/List of the clsOrder.
So with the CustomerID, I want to have the whole Collection/Array/List of
the clsOrder of this Customer...

Thanks a lot in advance,

Pieter

Aug 8 '05 #2
Huh? What are you talking about? I din't find anything about a
"FeederCollection"? even when looking for it on google I din't find any
website!!
Are you sure that you write it like that? because I don't get a clue?
"Jignesh Desai" <ji***********@hotmail.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
Take a look into CollectionBase class
public class FeederCollection : CollectionBase
Regards
Jignesh Desai - MVP
Blogs @ http://dotnetjini.jigneshdesai.com/Blogs/default.aspx
.NET Training Programs : http://dotnetjini.jigneshdesai.com/Training.aspx
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
Hi,

I want a fast way to use assign a tha values in a DataTable to a
collection/Array/List of Classes. Each record in my DataTable should be

new
Class, and tha Class would have property's for each Field in the

DataTable.

Is something like this possible? Or how should I do something like this?

A more practical exemple:
I have a Class clsCustomer, which contains many orders: so a
Collection/Array/List of the clsOrder.
So with the CustomerID, I want to have the whole Collection/Array/List of the clsOrder of this Customer...

Thanks a lot in advance,

Pieter


Aug 8 '05 #3
Pieter,

Assuming that you mean with classes instanced objects, than in my opinion is
your class on the same level as the arraylist or whatever.

And therefore is in my opinion just a for loop from the datatable, something
as

Dim myarraylist as new arraylist
For each row as datarow in myDatatable
dim myObject as new myClassBeNeLux
MyObject.TheCountry = col("Country")
if MyObject.TheCountry = "Belgium" then
MyObject.CorrectRoute = "Probably false"
end if
Next

In my opinion you cannot do it quicker using reflection or something what
you maybe expect You can maybe make a shorter routine using that, however
the processing time will probably be longer. You know something the same as
directing almost everybody except the first over a wrong route.

:-)

Cor


"DraguVaso" <pi**********@hotmail.com> schreef in bericht
news:uF**************@tk2msftngp13.phx.gbl...
Hi,

I want a fast way to use assign a tha values in a DataTable to a
collection/Array/List of Classes. Each record in my DataTable should be
new
Class, and tha Class would have property's for each Field in the
DataTable.

Is something like this possible? Or how should I do something like this?

A more practical exemple:
I have a Class clsCustomer, which contains many orders: so a
Collection/Array/List of the clsOrder.
So with the CustomerID, I want to have the whole Collection/Array/List of
the clsOrder of this Customer...

Thanks a lot in advance,

Pieter

Aug 8 '05 #4
hello dragu,

sounds like you want to do O/R-mapping (object-relational-mapping). (Google
for that word for more help on this topic)

But maybe a typed dataset is just what you want. With a typed dataset you
can access the value of each column through a property.

regards,
Felix

"DraguVaso" <pi**********@hotmail.com> schrieb im Newsbeitrag
news:uS*************@TK2MSFTNGP10.phx.gbl...
Huh? What are you talking about? I din't find anything about a
"FeederCollection"? even when looking for it on google I din't find any
website!!
Are you sure that you write it like that? because I don't get a clue?
"Jignesh Desai" <ji***********@hotmail.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
Take a look into CollectionBase class
public class FeederCollection : CollectionBase
Regards
Jignesh Desai - MVP
Blogs @ http://dotnetjini.jigneshdesai.com/Blogs/default.aspx
.NET Training Programs : http://dotnetjini.jigneshdesai.com/Training.aspx
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
> Hi,
>
> I want a fast way to use assign a tha values in a DataTable to a
> collection/Array/List of Classes. Each record in my DataTable should be

new
> Class, and tha Class would have property's for each Field in the

DataTable.
>
> Is something like this possible? Or how should I do something like
> this?
>
> A more practical exemple:
> I have a Class clsCustomer, which contains many orders: so a
> Collection/Array/List of the clsOrder.
> So with the CustomerID, I want to have the whole Collection/Array/List of > the clsOrder of this Customer...
>
> Thanks a lot in advance,
>
> Pieter
>
>



Aug 8 '05 #5
Hehe ok thanks :-)

And your example was really nice and to the point! Great! (*tssssssssss*)
hehe :-)
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Pieter,

Assuming that you mean with classes instanced objects, than in my opinion is your class on the same level as the arraylist or whatever.

And therefore is in my opinion just a for loop from the datatable, something as

Dim myarraylist as new arraylist
For each row as datarow in myDatatable
dim myObject as new myClassBeNeLux
MyObject.TheCountry = col("Country")
if MyObject.TheCountry = "Belgium" then
MyObject.CorrectRoute = "Probably false"
end if
Next

In my opinion you cannot do it quicker using reflection or something what
you maybe expect You can maybe make a shorter routine using that, however
the processing time will probably be longer. You know something the same as directing almost everybody except the first over a wrong route.

:-)

Cor


"DraguVaso" <pi**********@hotmail.com> schreef in bericht
news:uF**************@tk2msftngp13.phx.gbl...
Hi,

I want a fast way to use assign a tha values in a DataTable to a
collection/Array/List of Classes. Each record in my DataTable should be
new
Class, and tha Class would have property's for each Field in the
DataTable.

Is something like this possible? Or how should I do something like this?

A more practical exemple:
I have a Class clsCustomer, which contains many orders: so a
Collection/Array/List of the clsOrder.
So with the CustomerID, I want to have the whole Collection/Array/List of the clsOrder of this Customer...

Thanks a lot in advance,

Pieter


Aug 8 '05 #6
DraguVaso wrote:
Hi,

I want a fast way to use assign a tha values in a DataTable to a
collection/Array/List of Classes. Each record in my DataTable should be new
Class, and tha Class would have property's for each Field in the DataTable.

Is something like this possible? Or how should I do something like this?

A more practical exemple:
I have a Class clsCustomer, which contains many orders: so a
Collection/Array/List of the clsOrder.
So with the CustomerID, I want to have the whole Collection/Array/List of
the clsOrder of this Customer...

Thanks a lot in advance,

Pieter

Dragu.

There is a solution using Reflection to map your column names to your
property name. It is a little in-depth but if you want to go down this
route, let me know.

Regards
Ray
Aug 8 '05 #7
Thanks! That object-relational-mapping stuf seems really nice to me! I have
to look a little bit further into that subject!

"Felix Braun" <fe*@nexgo.de> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
hello dragu,

sounds like you want to do O/R-mapping (object-relational-mapping). (Google for that word for more help on this topic)

But maybe a typed dataset is just what you want. With a typed dataset you
can access the value of each column through a property.

regards,
Felix

"DraguVaso" <pi**********@hotmail.com> schrieb im Newsbeitrag
news:uS*************@TK2MSFTNGP10.phx.gbl...
Huh? What are you talking about? I din't find anything about a
"FeederCollection"? even when looking for it on google I din't find any
website!!
Are you sure that you write it like that? because I don't get a clue?
"Jignesh Desai" <ji***********@hotmail.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
Take a look into CollectionBase class
public class FeederCollection : CollectionBase
Regards
Jignesh Desai - MVP
Blogs @ http://dotnetjini.jigneshdesai.com/Blogs/default.aspx
.NET Training Programs : http://dotnetjini.jigneshdesai.com/Training.aspx

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uF**************@tk2msftngp13.phx.gbl...
> Hi,
>
> I want a fast way to use assign a tha values in a DataTable to a
> collection/Array/List of Classes. Each record in my DataTable should be new
> Class, and tha Class would have property's for each Field in the
DataTable.
>
> Is something like this possible? Or how should I do something like
> this?
>
> A more practical exemple:
> I have a Class clsCustomer, which contains many orders: so a
> Collection/Array/List of the clsOrder.
> So with the CustomerID, I want to have the whole
Collection/Array/List of
> the clsOrder of this Customer...
>
> Thanks a lot in advance,
>
> Pieter
>
>



Aug 9 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andreas Klemt | last post by:
Hello, let's say my session("myDataTable") is type of DataTable Now what is faster? a) Dim dv As New DataView(session("myDataTable")) b) Dim dv As New DataView(CType(session("myDataTable"),...
7
by: DraguVaso | last post by:
Hi, I want a fast way to use assign a tha values in a DataTable to a collection/Array/List of Classes. Each record in my DataTable should be new Class, and tha Class would have property's for...
7
by: DraguVaso | last post by:
Hi, I want a fast way to use assign a tha values in a DataTable to a collection/Array/List of Classes. Each record in my DataTable should be new Class, and tha Class would have property's for...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.