473,657 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why use a CollectionBase class here vs dataset or dataview?

jc
RE: Why use a CollectionBase class here vs dataset or dataview?

I'm looking at some vb.net 2005 code that was generated from a
homegrown Codesmith Template that generate all of the retreival and
update code for typical vb.net / asp.net data maintenance
applications. For some reason they have two class files for each
table, one is a collection class. Oddly both have the same properties
for each table column duplicated.. a lot of duplicate code and I'm
trying to understand why. Also, I'm trying to explain why the use of a
collection class anyways.

Perhaps the motivation was a more pure OOP approach, or perhaps
eventual scalability.

1. why the two classes?

Imports System.Configur ation.Configura tionManager
Namespace WH
Public Class Collaborator
Private m_ColId As Integer
Private m_Lastname As String
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property

and the other like this:

Namespace WH
Public Class colCollaborator
Inherits System.Collecti ons.CollectionB ase
#Region "List Data Structure"
Public Structure s_Collaborator
Private m_Result As String
Public Property ColId() As Integer
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property
Can't they be combined?

2. Sorry for the potentially noob OOP question, but why even use a
collection class? Any way to have a class that stores a dataset or a
dataview? And if not and a valid reason for the collection class, why
not one class file and one set of properties? The collection class
uses a reader to load the collection list..

Me.List.Add(Fro mDataReader(oRd r, blnAdd0Index))

Thanks for any help or information!
Jun 27 '08 #1
1 2584
jc,

One of the basics of OOP are the enumerable collections.

Look at this more simpliefied schema
Collection A holds a reference to another collection B which has a
Collection of
C. C is a simple item that only holds a back reference to B where it is in.
As you fill one C in table B you see in the debuger in quickwatch something
like this.

A
.B
C
B
C
B
etc. and that goes endless on, I did not try to show
this exact because as I see this in quickwatch I too have always to follow
the lines.

This is probably the reason that some people think that a dataset is a very
memory consuming thing, while it is only something as I tried to explain
above. In this sample there is only one item that holds a reference back to
B and is in that B collection, which is again referenced by A in a
collection.

A dataset is something that holds references to
-collections of relations which has a reference back to the dataset
-collections of tables which has a reference back to the dataset
-some name giving properties
-the collection of tables holds references to
-collections of columnames which have a reference back to the table
-collections of rows which have a reference back to the table
-some properties including the dataview which
has a reference back to the datatable
-the rows holds references to items which are in
fact the true object which holds the data.

In my idea it is because of that people don't understand this that they have
made all kind of solutiong so make by them so called lightweight
datacollection. In fact those are probably mostly consuming much more
resources.

Cor


"jc" <wi*****@noclie nt.netschreef in bericht
news:83******** *************** ***********@m45 g2000hsb.google groups.com...
RE: Why use a CollectionBase class here vs dataset or dataview?

I'm looking at some vb.net 2005 code that was generated from a
homegrown Codesmith Template that generate all of the retreival and
update code for typical vb.net / asp.net data maintenance
applications. For some reason they have two class files for each
table, one is a collection class. Oddly both have the same properties
for each table column duplicated.. a lot of duplicate code and I'm
trying to understand why. Also, I'm trying to explain why the use of a
collection class anyways.

Perhaps the motivation was a more pure OOP approach, or perhaps
eventual scalability.

1. why the two classes?

Imports System.Configur ation.Configura tionManager
Namespace WH
Public Class Collaborator
Private m_ColId As Integer
Private m_Lastname As String
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property

and the other like this:

Namespace WH
Public Class colCollaborator
Inherits System.Collecti ons.CollectionB ase
#Region "List Data Structure"
Public Structure s_Collaborator
Private m_Result As String
Public Property ColId() As Integer
Get
Return m_ColId
End Get
Set(ByVal value As Integer)
m_ColId = value
End Set
End Property
Can't they be combined?

2. Sorry for the potentially noob OOP question, but why even use a
collection class? Any way to have a class that stores a dataset or a
dataview? And if not and a valid reason for the collection class, why
not one class file and one set of properties? The collection class
uses a reader to load the collection list..

Me.List.Add(Fro mDataReader(oRd r, blnAdd0Index))

Thanks for any help or information!
Jun 27 '08 #2

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

Similar topics

1
4602
by: Arthur Dzhelali | last post by:
I according to MSDN dataview and dataset are thread safe for read operations, but we run into this scenario. I just would like to see some comments on it. Aplication written in VB.NET it is an ASP.NET app. located on busy web server. Initially we defined dataview slightly wrong and run into the problem. we have dataset cached which has large ammount of data.
4
2849
by: Siu | last post by:
Hi, I've written a class which inheritates from the CollectionBase class public class MyClass : CollectionBase { } An object istantiated from MyClass can be transformed in a DataSet? does exist a method which transform it into a DataSet?
2
5337
by: Dennis | last post by:
Hi, I am hoping I can get some help with a small problem I have run into using C#. U have an XML file that I load into a Dataset and then display this in a Datagrid. No problems doing this at all. I then use a Dataview to filter this view using a keyword and I have no problems with this either. What I would like to do is to save this Dataview to a new Dataset so I can save the reslts to a new file but here is where I am having the...
1
2898
by: Kyle Novak | last post by:
I have a question about strongly typed objects when looping through a collection based on the CollectionBase object and using a For..Each loop. I have 2 objects: -Invoice: Holds all properties related to an invoice -InvoiceCollection: Inherited from Collectionbase class and holds Invoice objects The InvoiceCollection class is as follows:
2
6959
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count, GetEnumerator, and RemoveAt) but the way it implements all the other things you need to override seems overkill and counters the advantage of having an extensible base class. For example, the documentation example implementation of Remove: Public...
0
2586
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create tablestyles to format any of the columns within the datagrid, the exception "Can-not parent objects created on one thread to objects created on another" or words to that effect. I'm not too sure if what I said make sense, but i will add details to...
17
2747
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
6
1917
by: Joseph I. Ceasar | last post by:
I have an ASP .Net 2.0 site that I am working on. It has a master page and a content page. I also created a separate class module that returns a DataSet to feed my GridView. So far, so good. The thing is that the method that returns the DataSet is computationally expensive and I really need to create the whole DataSet only once per session. Once it's created, I'd like to return the same DataSet to the GridView for operations such as...
11
2518
by: Sid Price | last post by:
I have Dataset that I need to filter into another Dataset for display and I can not find out how to do this. I have found methods for copying a Dataset but I can not see how to filter the rows copied using my query. I hoped to be able to use a DataAdaptor to do this but SelectCommand requires a connection and I don't see how to create a connection to my Dataset object. Any pointers would be much appreciated. Sid.
0
8420
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
8324
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
8842
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...
1
8516
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5642
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
4173
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...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1970
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.