Re: Getting data in class hierarchy (C#)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Miha Markic [MVP C#] (miha)
Date: 07/26/04


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.
>
>
>


Relevant Pages

  • Getting data in class hierarchy (C#)
    ... If I want just the MoreSpecficUser data then I just call its Load() method. ... public class MoreSpecficUser: User ... However it involves TWO database connections. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: .Net Scalability problem
    ... LoadRunner will peak out a server with a few virtual users. ... To get an idea of load, ... Fire off the test client and watch the number of ... > So I think that the MTC generate concurrent connection and per ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Resistance of ammeter caused voltage drop
    ... >> On power supplies supplied with external sense compensation there are ... >> load at the same point the supply lead is connected to the load, ... the sense terminals ... >with cable and connection drops, ...
    (sci.electronics.design)
  • Re: Resistance of ammeter caused voltage drop
    ... >> On power supplies supplied with external sense compensation there are ... >> load at the same point the supply lead is connected to the load, ... the sense terminals ... >with cable and connection drops, ...
    (sci.electronics.basics)
  • Re: Diagnosing SqlCeConnection memory-load issue
    ... The issue could be that SQL CE engine unloads and loads for every connection close and open and hence keeping the connection open has become a practice. ... The memory load of the system goes up, ... I have a static database-Manager object that has a> SqlCeConnection ...
    (microsoft.public.sqlserver.ce)