Re: Getting data in class hierarchy (C#)
From: Miha Markic [MVP C#] (miha)
Date: 07/26/04
- Next message: Paul Clement: "Re: dev connections work, test does not"
- Previous message: Miha Markic [MVP C#]: "Re: How to use SQLBinary?"
- In reply to: MattC: "Getting data in class hierarchy (C#)"
- Next in thread: Jouni Heikniemi: "Re: Getting data in class hierarchy (C#)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 26 Jul 2004 15:00:15 +0200
Hi Matt,
Acutally you've used only one physicall sql connection :-).
Connection is reused while it is not being active (as in your case).
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
"MattC" <m@m.com> wrote in message
news:u6mqN1ucEHA.3096@tk2msftngp13.phx.gbl...
> I have a class hierarchy that is, for simplicity sake, two levels deep.
>
> User -> MoreSpecificUser
>
> In most cases it will only be necessary for me to retrieve information for
> one or the other. I figure if I dont need all the data that the parrent
has
> to offer why get it.
>
> So here was my solution, I have an interface that all classes must
> implement, this exposes Save, Load and Delete.
>
> If I want just the MoreSpecficUser data then I just call its Load()
method.
> If I want the parent info I call base.Load().
>
> Fine the coupling is low and maintenance is easy.
>
> Here's my only quibble. If I wanted to do this:
>
> public class User: IMyInterface
> {
> public void Load()
> {
> //open db connection
>
> //fill dataset
>
> //unpack dataset and fill load object members
>
> //close connection
> }
> }
>
> public class MoreSpecficUser : User
> {
> //other interface implementations here
>
> public override void Load()
> {
> base.Load();
>
> //open db connection
>
> //fill dataset
>
> //unpack dataset and fill load object members
>
> //close connection
> }
> }
>
> As you acn see I've simply called the base Load method to get all the info
> available to this user. However it involves TWO database connections. Now
> this make life easy in terms of code maintenance and flexibility in the
app
> but not sure how comfortable I am about makng two connections to fill and
> object.
>
>
>
- Next message: Paul Clement: "Re: dev connections work, test does not"
- Previous message: Miha Markic [MVP C#]: "Re: How to use SQLBinary?"
- In reply to: MattC: "Getting data in class hierarchy (C#)"
- Next in thread: Jouni Heikniemi: "Re: Getting data in class hierarchy (C#)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|