473,837 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Inde x as Integer) or
Collection(KeyN ame 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 3961
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((Collection Item as MyType) method on your class, you will have
all you need.
You could also implement System.Collecti ons.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 StringCollectio n class in .Net
Framework (download rotor source and go to
fx\src\compmod\ system\collecti ons\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.n et> wrote in message
news:uc******** *****@tk2msftng p13.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(Inde x as Integer) or
Collection(KeyN ame 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
296
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 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...
7
2156
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
3099
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 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Declare your object variables
5
1286
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 the properties of each MyItem in MyCollection I need set a special ID to each property of MyItem, and for this, I need access to my principal class, but... each item of MyCollection is created at desing time... i can't pass an object as argument...
6
1468
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 example I found on the web. I would be most appreciative if someone could explain why this statement is necessary and what does it do: MyArt = New Art
12
3184
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 restarting the application. What I did was to create an AppDomain that loaded the plugins and everything was great, until I tried to pass something else that strings between the domains...
1
9362
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 GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
5
3796
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 List<RoleData> GetRoles() { return GetRoles(null, false); }
3
3024
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 already wrote but i'm having problem to move forward. my problem is : 1. how do i assign each checkbox to have equal value with the value of the d_id?
0
9843
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10577
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9407
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7005
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4476
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.