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

Question about Class Hierarchy and ADO.Net


Hello,

I am wondering about best practices for class hierarchies and using
ADO.Net, especially the DataSet update/delete commands and the data
relations... this needs to package/unpackage to xml for client/server
sending. The class properties pretty much correspond to database tables.

This is a pretty long question so thanks in advance for reading and
commenting!

Clinics class - collection of Clinic objects
Clinic
Guid
Name
(a few other properties)
Exams class - collection of Exam objects
Exam
Guid
CreateDate
CreateByUserGuid (User class)
SpecialistUserGuid (User class)

Captures class - collection of Captures
Capture
Guid
Date
CaptureTypeCode
etc.

Users class
User
Guid
Name
Email

In VB6 for the singular classes (Exam, Clinic, Capture), I used a
private adodb recordset fields variable (with the schema from the table)
to hold most of the variables, and the get and let methods getting and
letting from the rs field. eg,

private m_fields as ADODB.Fields

Public Property Get Name() As String
Name = m_fields("Name")
End Property

Friend Property Let Name(vData As String)
m_fields("Name") = vData
End Property

I also had an update method which updated the table directly from the
fields variable or sent in the values of the fields to an AddUpdate
stored proc. The collection classes (Exams, Clinics, Captures) also had
an update method which went through all the singular objects and called
that update method.

The main advantages of this was that having a recordset was more
efficient then having local variables for each property and having to
set all of them vs just setting a recordset. also clean and easy code,
and extensible by adding new fields to the db table. The disadvantage
was that each there was a lot of database hits to build the whole object
(even with lazy loading) - because as we get further building the
hierarchy, we can query for the same user guid for example. ie,

Exam instance #1 does a query for UserGuid 123
Exam instance #2 does a query for UserGuid 222
Exam instance #3 does another query for UserGuid 123
Exam instance #5 does another query for userGuid 222

So, to get to the heart of my question, I would like to use ado.net's
new features to do two things across class boundaries...

(1) from a collection class (Exams) with a dataset and add/update/delete
commands defined, to send individual datarows to each individual class
(exam), sort of like pass in the datarow by reference. Thus, I can do
an update from the collection class level (Exams) with those
add/update/delete commands. I would also like to be able to do an
add/update/delete from the individual class level too (Exam), because I
would like to be able to easily create a new Exam or whatever. Also, I
would like to package it up as xml and then open it on another computer
and save to db.

(2) use ado.net's data relation to reduce the amount of sql queries...
for example with my object model above, I would like to do one query for
all Clinics that meet a criteria, then one query for all the exams in
those clinics, then all the captures for those exams, then all users for
the exams and clinics, etc. if i had to do it in a similar way i id it
in vb6, i guess i could use some caching techniques and checking to see
if i have gotten that guid for a particlar class already?

Note that I don't want to do anything like use static varibles to hold
DataSets with relations, because I want to be able to have multiple
instances obstantiated without interfering with each other.

Any ideas, comments, pointers or references highly appreciated... most
of the ado.net books and articles seem to be for a more two tiered
approach with using ado.net in the presentation layer, i would like to a
more n-tiered approach.

many thanks,

-ed
Nov 16 '05 #1
0 1593

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

Similar topics

5
by: Gonçalo Rodrigues | last post by:
Hi all, (note: newbie alert) Suppose you have a hierarchy of objects that you deal with via smart pointers, e.g. something like: template<typename T> class Ref { private:
31
by: grahamo | last post by:
This came up in an interview I did a while ago and I wanted to know the correct answer. The setup is this; If I have a base class "food" and also two classes "meat" and "veg" that inherit from...
12
by: Meya-awe | last post by:
I am puzzled, what is the purpose of an interface? How does it work, what i mean is how does the compiler treats this? Why when we talk about separating user interface from business logic, an...
24
by: Kalpesh | last post by:
Hello All, Please help validate this design problem Assume that I have several entities in my project (eg Supplier, Customer etc). All of them save several common properties - name, address,...
2
by: K Viltersten | last post by:
Suppose there is the following class structure. class S {...} class A : S {...} class B : S {...} class A1 : A {void m(){...}} class B1 : B {void m(){...}} class B2 : B {...} Just to clarify...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.