473,395 Members | 1,931 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,395 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
Nov 21 '05 #1
7 927
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

Nov 21 '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


Nov 21 '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

Nov 21 '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
>
>



Nov 21 '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


Nov 21 '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
Nov 21 '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
>
>



Nov 21 '05 #8

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

Similar topics

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...
3
by: Michael | last post by:
I'm using windows forms! >-----Original Message----- >Are you using ASP.NET or Windows Form? Only Windows Forms >DataGrid support that method. > >Tu-Thach > >>-----Original Message-----
5
by: John Lee | last post by:
Hi, I created a strong-typed (Class1) collection class for my web service, it actually serialized to <ArrayOfClass1 /> and I need to make the root named as <Class1Collection /> so I was trying...
3
by: vertigo | last post by:
Hello When i try: MyClass myClassObject = new MyClass(); ArrayList myArrayList; myArrayList.Add(myClassObject); where MyClass is my own class What's wrong ?
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"),...
0
by: Serge Poirier | last post by:
Good Day Folks, I found a sample on MSDN illustrating Master/Detail. I've tried it but it doesn't seem to do anything. Any ideas on how to make it work ? Thanks in advance /Serge
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
7
by: NEWS | last post by:
I want to display data in a VB.NET DataGrid - but the data is from my VB code, not bound to a database. I am using code like this :- DataGrid1.Item(1, 1) = "Test" I keep getting the message...
15
by: Brett Romero | last post by:
I have this class: public class MyClass<TValue> where TValue : IMyClass, new( ) {...} I need to create a class that will hold instances of the above class using List<>: public class...
1
by: tbo | last post by:
The code below works fine to update my database by adding rows of data to my dataTable. However when I use the same commands (changing the names of database, datatable and rows) with another...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.