Collection of a class to use as worktable

  • Thread starter Thread starter Reynaert Kristien
  • Start date Start date
R

Reynaert Kristien

Hi,

I need some kind of unbound table in which i can add and edit items
I must be able to read items by ID and update some fieldvalues.
At the end of the program i will have to read all items of this table and
use the values to update some "real" (other) tables
So i need some kind of 'worktable' to store my data temporary

I think i have to make a class in which i define my fields of my worktable
and then work with some collection of that class, but i don't quite know
exactly how to do this

Someone who can give me some hints in what i should use?
Thanks,
Kristien
 
Hi,

I need some kind of unbound table in which i can add and edit items
I must be able to read items by ID and update some fieldvalues.
At the end of the program i will have to read all items of this table and
use the values to update some "real" (other) tables
So i need some kind of 'worktable' to store my data temporary

I think i have to make a class in which i define my fields of my worktable
and then work with some collection of that class, but i don't quite know
exactly how to do this

Someone who can give me some hints in what i should use?
Thanks,
Kristien

Sounds an awful lot like a dataset to me... You can create and setup a
dataset in memory.
 
Reynaert Kristien said:
Hi,

I need some kind of unbound table in which i can add and edit items
I must be able to read items by ID and update some fieldvalues.
At the end of the program i will have to read all items of this table and
use the values to update some "real" (other) tables
So i need some kind of 'worktable' to store my data temporary

I think i have to make a class in which i define my fields of my worktable
and then work with some collection of that class, but i don't quite know
exactly how to do this

Someone who can give me some hints in what i should use?
Thanks,
Kristien

You would have a public class with public properties.

<http://www.vbdotnetheaven.com/Uploa...Net04192005060237AM/PropertiesInVbDotNet.aspx>

You would instanciate the class new an object and set the object's public
properties each time.


You can use a List<T> a collection.

dim myobjects = new List<MyObject>

If the object/class was named MyObject, then in some kind of loop to load
the object into the collection.

dim obj = new MyObject

obj.ID = 1
obj.Name = "help"

myobjects.add(myobjects)

Now MyObject iis in a collection of objects myobjects.

If you have .Net 3.0 Framework or better, the you can use Linq to query the
collection for a MyObject in myobjects by ID as an example and make the
chenges to the object.

If you don't have Linq, then you'll need to make an function or method to
address the object in the collection using a foreach loop
..
foreach(myobject in myobjects)

if myobejct.ID = passedID then
myobject.Name = "Help"
endif

You would walk the collection using a loop to read each object in the
collection to sent to a SQL table or whatever.

foreach(myobject in myobjects)

TableNameField = myobject.Name

It's an example of of OOP's Object Oriented Programming.

You don't need a worktable, but instead you need to understand OOP's,
gernerics and collections.
 
Reynaert Kristien said:
Hi,

I need some kind of unbound table in which i can add and edit items
I must be able to read items by ID and update some fieldvalues.
At the end of the program i will have to read all items of this table and
use the values to update some "real" (other) tables
So i need some kind of 'worktable' to store my data temporary

I think i have to make a class in which i define my fields of my worktable
and then work with some collection of that class, but i don't quite know
exactly how to do this

Someone who can give me some hints in what i should use?
Thanks,
Kristien
Have you thought of using a Dictionary. You add the classes to the
dictionary and use your ID field as the key.
So you would have something like: MyDictionary("1234").FieldOne etc
 
Reynaert Kristien said:
Hi,

I need some kind of unbound table in which i can add and edit items
I must be able to read items by ID and update some fieldvalues.
At the end of the program i will have to read all items of this table and
use the values to update some "real" (other) tables
So i need some kind of 'worktable' to store my data temporary

I think i have to make a class in which i define my fields of my worktable
and then work with some collection of that class, but i don't quite know
exactly how to do this

Someone who can give me some hints in what i should use?
Thanks,
Kristien

----

Thank you for all the suggestions
I think Dictionary will be the best and easiest to use in my project.
As like with List<T>, i can work with a public class to put my values, and
it's easy to add, edit and iterate in the dictionary

I have .Net Framework 3.5 so if using list<T> i could use Linq to retreive
data. But i was struggling with the syntax to find the best way to edit a
value of an object
I would do it like:
Dim record As MyObject= (From myObject In myList _
Where myObject.[ID].Equals("aaa") _
Select myObject).SingleOrDefault()
If record IsNot Nothing Then
record.field1= True
End If
But as i found in definition of Select that parameters are ByVal, i don't
understand that my object in the list would be changed as i don't see that
'record' is a reference to my object. i didn't try it out though

Anyways, thank you all for your time to help me to move on with my project

Kristien
 
Back
Top