473,396 Members | 1,755 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,396 software developers and data experts.

Help in creating a collection class

Here's the situation.
I am developing an ASP.NET web application. Most of my forms will be
accessing a database (MS Access) for either record
creation/deletion/updating or for list lookups. The problem I have is my
boss constantly wants to revise table and field names and I am the one that
has to make sure everthing works after the fact. What I want to do is
create 2 classes.

The first one is my "Record" wrapper class that will map to the table field
names. This is to provide me a consistant interface so when the database
field name is changed, all I have to do is change the field mapping in this
class.

The second class is my "Records" collection. I can create the database
methods myself, but I need to be able to set the rest of the interface up
and this is where I get a little confused. There are several different
collection objects available: array, arraylist, collection, dictionary...
I'm not sure what the best method is and how to go about implementing it.
What are your recomendations for this? I was able to do this easily in VB6,
but I'm not sure how to do it in .NET

1: I need to be able to use For Each Next... syntax
2: I need to be able to use either the Collection(Index as Integer) or
Collection(KeyName as String) methods to access an item.
3: I need to be able to strict types. Collection.Add(CollectionItem as
MyType)
4: Sorting is not needed. I will accomplish this in my SQL string.
4: Performance is an issue, but ease of use and functionality is a higher
priority.

Can anybody help explain what I need to do, and/or point me to some good
examples on the web where I can learn how to do it?

TIA,
-Matt
Jul 19 '05 #1
1 3921
In your case, you can simply implement IEnumerable on your class, which will
alow you to use For Each.
You can use add index methods on your class to support 2.
Just add Add((CollectionItem as MyType) method on your class, you will have
all you need.
You could also implement System.Collections.IList on your class, but this
interface contains many methods you might not want to implement.
The advantage of implement IList is that you can use your collection on many
framework methods, which might not be important for you.

You can look at the implementation of StringCollection class in .Net
Framework (download rotor source and go to
fx\src\compmod\system\collections\specialized.)
Or down a strong-typed collection sample from
http://www.gotdotnet.com/Community/U...6-d9d8d7951ddc

Hope this helps,
Gang Peng
[MS]

"Matthew Hood" <ms****@qwest.net> wrote in message
news:uc*************@tk2msftngp13.phx.gbl...
Here's the situation.
I am developing an ASP.NET web application. Most of my forms will be
accessing a database (MS Access) for either record
creation/deletion/updating or for list lookups. The problem I have is my
boss constantly wants to revise table and field names and I am the one that has to make sure everthing works after the fact. What I want to do is
create 2 classes.

The first one is my "Record" wrapper class that will map to the table field names. This is to provide me a consistant interface so when the database
field name is changed, all I have to do is change the field mapping in this class.

The second class is my "Records" collection. I can create the database
methods myself, but I need to be able to set the rest of the interface up
and this is where I get a little confused. There are several different
collection objects available: array, arraylist, collection, dictionary...
I'm not sure what the best method is and how to go about implementing it.
What are your recomendations for this? I was able to do this easily in VB6, but I'm not sure how to do it in .NET

1: I need to be able to use For Each Next... syntax
2: I need to be able to use either the Collection(Index as Integer) or
Collection(KeyName as String) methods to access an item.
3: I need to be able to strict types. Collection.Add(CollectionItem as
MyType)
4: Sorting is not needed. I will accomplish this in my SQL string.
4: Performance is an issue, but ease of use and functionality is a higher
priority.

Can anybody help explain what I need to do, and/or point me to some good
examples on the web where I can learn how to do it?

TIA,
-Matt

Jul 19 '05 #2

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

Similar topics

1
by: Matthew Hood | last post by:
Here's the situation. I am developing an ASP.NET web application. Most of my forms will be accessing a database (MS Access) for either record creation/deletion/updating or for list lookups. The...
7
by: Robin | last post by:
In a current .Net solution (using VB.Net) has a 3 tier architecture of Web interface, Data Access Layer and Database. How do I implement business logic and class layers into this solution?
9
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
5
by: Arnold | last post by:
Hi, Im building a WebCustomControl. In my principal class (Inherits from WebControl), have a property of type MyCollection (Inherits from CollectionBase), which is a MyItem collection. To mantain...
6
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the problem solving statement is necessary. The inspiration for the statement came from an undocumented VB...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
3
by: cuties | last post by:
Hi all.... i'm very new to this programming language. i'm required to fulfill this task in the company i'm doing my practical. i hope i can get guide for my problem... Here is the script i...
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
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?
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
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
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...
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...
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,...

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.