473,772 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extra db read in business object class

I'm not sure if this is the right forum, but here it goes :-)

This has been bothering me for a long time, and I'm curious about everyone's
opinion or a "Microsoft Best Practices" method of doing this. I have a
"Member" business object which contains information about an individual
member. For instance, it contains the following properties:

member.name = "SteveS"
member.LoginNam e = "SteveS"
member.Phone = '555-555-1234'
member.Office = ...object of office information such as (office.address 1,
office.name, office.mailtype , etc...)
member.Committe es = ....contains a collection of the Committee objects
(Committee.Name , Committee.Type, Committee.Meeti ngPlace, etc...)

So, every time I instantiate the member object, I populate the .Office and
..Committes objects. Basically, in this example, the database would take 3
hits - one to read the member record, one to read the office record, and
one to read the committee records.

THE PROBLEM: This works fine, except there are 2 extra database hits when
I only need the LoginName property. ***I hate to call the database again if
I don't have to****

THE SOLUTION: ???? What do you think is the best answer???? Once answer
is to read all the data in a sql statement, then use that to populate each
object. That doesn't seem to be the cleanest way to me. (but I could be
wrong). Here's what I did:
Public Class Member

private _name as string
private _MemberNumber as Long
private _LoginName as string
private _Phone as string
private_Office as Business.Office
private _Committees as Business.Commit teCollection()

Public Property Name as String
....
End Property
Public Property LoginName as String
....
End Property
Public ReadOnly Property as Business.Office
Get
If IsNothing(_offi ce) then '<======= populate the office object
if not already
_Office = New Office(_OfficeN umber)
End If
End Get
End Property
Public ReadOnly Committees Property as Business as
Business.Commit teeCollection()
Get
If IsNothing(_Comm ittees) Then '<=======popula te the
CommitteCollect ion if not already
...code to populate the CommitteCollect ion.....
End If
return _Committees
End Get
End Property
.....
.....
End Class
Thanks for taking the time to think about this :-)

SteveS

Nov 20 '05 #1
0 909

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

Similar topics

1
1360
by: SteveS | last post by:
This has been bothering me for a long time, and I'm curious about everyone's opinion or a "Microsoft Best Practices" method of doing this. I have a "Member" business object which contains information about an individual member. For instance, it contains the following properties: member.name = "SteveS" member.LoginName = "SteveS" member.Phone = '555-555-1234' member.Office = ...object of office information such as (office.address1,...
16
3039
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
39
3100
by: JKop | last post by:
Back when I read my first C++ book, I was given the following scenario: class Cheese { public: int number_of_holes; int colour;
3
4241
by: Koen | last post by:
Hi, first of all, the machine setup server 1: - UDB2 7.2.5; COUNTRY=1, location = US, IBM1250 codepage - Locale: US English; Regional Settings: English; Keyboard: Dutch; decimal separator: . server 2: - UDB2 7.2.5 Client Tools - Websphere 4.0.5
8
1937
by: ad | last post by:
I have studied buisness layer in http://beta.asp.net/QUICKSTART/util/srcview.aspx?path=~/aspnet/samples/data/GridViewObject.src It separate Author class to Author and AuthorComponent If I combine the two together into Author Class for convenience, like codes below: Is it ok to do that?
5
3139
by: Shibu | last post by:
Hi, I have a situation where I need to convert business objects to a flat table. The reverse is also required. I am using c# and Oracle ODP. I am looking for an easier method to do the below steps. Steps I follows for populating Business Objects is as follows (1) Get a list of records containing various tables joined together from DB using a single PL/SQL (This is a specific requirement, So cannot change the design)
9
6263
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the two different ways to handle this table. CASE 1 : create a struct that encaplusates table "Customers" columns public struct structCustomers { public string CustomerID;
1
1885
by: Nemisis | last post by:
hi guys, Currently converting an old classic asp system to a OOP asp.net application. We are building the new application using a 3 tier arcitecture and i was wondering about the following. I have a parent class, that when inserted, inserts a few child classes into the database, based on other classes. In the old system, this is wrote as one big SQL script, with many inserts and updates because the system was not wrote as OOP.
5
3466
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration: default.aspx:
0
10103
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...
1
10038
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
8934
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
7460
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
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.