Hi Jeff, as I told to Christopher the ObjectDataSource class of ASP.NET 2.0
serve as DataSource to bind a business entity with an ASP.NET 2.0 control
like GridView (note that it's a bidirectional binding):

GridView <---> ObjectDataSource <--+--> my 'Author' Business Entity (Update)
                                   |
                                   +->  my 'AuthorsList' B.E. (Select)

but I cannot do this side

  ObjectDataSource <--+--> my 'Author' Business Entity (Update)
                      |
                      +->  my 'AuthorsList' B.E. (Select)

because
1) ObjectDataSource require the Update() method in Author to have atleast 1
parameter
2) ObjectDataSource require Update() and Select() methods to be in the same
class while Update() is in my 'Author' class and Select() is in
my 'AuthorsList'.

To overcome these limitations I had to write the
adapter/wrapper 'AuthorsWrapperForObjectDataSource' class so now I can do
this:

 ObjectDataSource <---> AuthorsWrapperForObjectDataSource
                          ^  ^
                          |  |
                          |  +--> my 'Author' Business Entity (Update)
                          |
                          +--> my 'AuthorsList' B.E. (Select)


In my opinion ObjectDataSource should let me bind it directly to
Author.Update() and AuthorsList.Select(...) without the need of the
AuthorsWrapperForObjectDataSource wrapper/adapter.

(luKa)

http://nullabletypes.sf.net/
http://dev.luca.minudel.it/
http://www.luca.minudel.it/eng/





On Thu, 7 Jul 2005 07:29:58 -0700, jeff hughes <[EMAIL PROTECTED]> wrote:

>A more OO approach to this would be to create an interface that your
>entire object inherits from which are to be persisted to the database.
>
>Public class author : IPersistable
>{
>        ....
>}
>
>This class should also know nothing about how the data is persisted just
>that it contains what is required to get persisted.
>
>You should then have an object that knows about IPersistable and how to
>persist this interface to the database.
>
>Public class service
>{
>        Public IPersistable persist(IPeristable)
>        {
>                .... this is the were the code for the database persist
>would                   occur
>        }
>
>}
>
>You could then have a service object work like:
>It gives it polymorphic behavior since now you can create a book class
>that also inherits from IPeristable and pass that into the persist
>method as well. BTW, you will still have to handle the different types
>of objects within the persist method but you can create private method
>to do this internally and just call the appropriate private persist
>based on the type of object passed in. It provides the end programmer a
>cleaner solution for data access.
>
>
>
>-----Original Message-----
>From: Unmoderated discussion of advanced .NET topics.
>[mailto:[EMAIL PROTECTED] On Behalf Of Christopher
>Reed
>Sent: Thursday, July 07, 2005 6:46 AM
>To: [email protected]
>Subject: Re: [ADVANCED-DOTNET] ASP.NET 2.0 ObjectDataSource poor design?
>
>How can you update a data record (or set of records) without passing in
>the changed information as parameters?
>
>Christopher Reed
>Web Applications Supervisor
>Information Technology
>City of Lubbock
>[EMAIL PROTECTED]
>"The oxen are slow, but the earth is patient."
>
>>>> [EMAIL PROTECTED] 4:12:38 PM 7/6/2005 >>>
>In a Business Layer with Busines Entities with CRUD Behaviors (has
>described here [1] at Cap. 'Defining Custom Business Entity Components
>with CRUD Behaviors') typically
>1) the Update() method have zero parameters
>2) the Update() method is in a Business Entity class say Author, while
>the SelectAuthorsByXxx() methods that get filtered lists of authors is
>in another Business Entity say Authors class.
>
>But... ObjectDataSource:
>1) don't let me set a method with zero parameters to UpdateMethod!
>2) don't let me set SelectMethod and UpdateMethod from 2 different
>classes!
>
>To use ObjectDataSource in real world application I had do write a
>wrapper like this:
>
>public static class AuthorsWrapperForObjectDataSource {
>    public static List<Author> SelectAuthorsByState(string state, string
>sortExpression)   {
>        return AuthorsList.GetAuthorsByState(state, sortExpression);
>    }
>
>    public static int UpdateAuthor(Author author) {
>        return author.Update();
>    }
>}
>
>I have to write a wrapper for ObjectDataSource also when I have a
>Business Layer with Busines Entities without CRUD Behaviors (has
>described here [1] at Cap. 'Defining Custom Business Entity
>Components').
>
>Am I missing the correct usage of ObjectDataSource or someone else noted
>these ObjectDataSource limitations?
>
>TIA (luKa)
>
>http://nullabletypes.sf.net/
>http://dev.luca.minudel.it/
>http://www.luca.minudel.it/eng/
>
>
>[1] Designing Data Tier Components and Passing Data Through Tiers,
>Microsoft, 2002
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/h
>tml/BOAGag.asp
>
>===================================
>This list is hosted by DevelopMentor(r)  http://www.develop.com
>
>View archives and manage your subscription(s) at
>http://discuss.develop.com
>
>===================================
>This list is hosted by DevelopMentorĀ®  http://www.develop.com
>
>View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to