473,320 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1218
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.