473,795 Members | 2,983 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 3957
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
2155
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
3094
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
1285
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
1466
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
3176
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
9358
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
3793
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
3019
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
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
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
10001
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
9042
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...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
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
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.