Re: n-tier best practices

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

From: rodchar (rodchar_at_discussions.microsoft.com)
Date: 09/13/04


Date: Mon, 13 Sep 2004 13:11:01 -0700

If I create a business object how would I expose the dataset, like to use in
a datagrid?

"Andrew Faust" wrote:

>
> "rodchar" <rodchar@discussions.microsoft.com> wrote in message
> news:B00106D8-5731-4AAD-944B-0AFABBBD38AB@microsoft.com...
> > The dataset I'm referring to lives in the UI on Form1. What I'm
> > wondering is
> > if, let's say, you have form1 that shows a collection of parent
> > records. You
> > click on one and it takes you to form2 to show the details of
> > that parent.
> > Now, let's say from form2 you can open form3 to display the
> > chidlren rows.
> > And then, the user clicks on the collection to view the child
> > details on
> > form4.
> >
> > How would I persist the dataset, especially if you're going
> > back and forth
> > doing updates between form3 and form4?
>
>
> > My idea, which I'm not sure is a good practice or not is to
> > pass the
> > dataset, which lives in form1, byRef between the 4 forms. Or is
> > there a
> > better way?
>
> Ok. That gives a bit better clarification. First thing you will
> usually want to do is to seperate the presentation layer (forms)
> from the data layer. Don't have the forms themselves doing the
> data retrieval and updates. Instead create a class that handles
> all the data operations. Then you could be passing a reference to
> this class around to all the different forms. This way if you
> make a change to the data class, then when you refresh your view
> on the other forms, the updates will appear, because they are
> referencing the same object.
>
> If changes need to be made to your dataset that you are passing
> around, then I probably wouldn't pass just the plain dataset. I
> would pass a class which handles all data operations, then let
> that class make any changes necessary. This way if you ever need
> to change some crucial pieces about how the data is stored or
> handled, you can make the changes just in the one class, rather
> than in all classes that use it.
>
> If all these forms are not changing the data, but rather for
> display only, then I would just go ahead and pass the data set.
>
> Hope this helps,
>
> Andrew Faust
>
>
>



Relevant Pages

  • Re: n-tier best practices
    ... You could have a function of your data class to retrieve the data ... > If I create a business object how would I expose the dataset, ... Then you could be passing a reference ...
    (microsoft.public.dotnet.general)
  • Re: n-tier best practices
    ... Take another instance if you will, 2 forms that share a business object. ... I can pass a datarow from form1 to form2, and on form2 bind the row to the ... Then you could be passing a reference to ...
    (microsoft.public.dotnet.general)
  • Object References - got a blackout
    ... I'm calling a function, passing the reference of a ... business object for editing. ... object itself to the reference. ... public static bool EditMyObject(ref MyObject o) ...
    (microsoft.public.dotnet.languages.csharp)
  • How Can I Use The Com+ Server From Client
    ... on COM+ server) and the database ... I want that my client applications able to call the methods ... of business object across machine. ... When I open the "Add Reference" dialog box, ...
    (microsoft.public.dotnet.framework.interop)
  • Re: EventArgs
    ... it's a pain to keep them all straight when some get changed or removed ... and you'd be better off passing in a business object. ... Especially in constructors. ...
    (microsoft.public.dotnet.languages.csharp)