Results 1 to 11 of 11

Thread: [RESOLVED] [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Resolved [RESOLVED] [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    Hi guys,

    u know those: insert, Update, delete methods in the BLL layer. WE always have to add them manually, but many times, they reflect pretty much the insert, update, select methods from trhe typed Dataset that we design in the dataset deaigner

    So my question pls:

    Instead of typing for example:


    <System.ComponentModel.DataObjectMethodAttribute _
    (System.ComponentModel.DataObjectMethodType.Update, False)> _
    Public Function Update_CarnetAddress(ByVal id As Integer, ByVal Entreprise As String, ByVal Contact As String, ByVal Telephone As String, ByVal Email As String, ByVal Fax As String, ByVal Note As String, ByVal ModifierPar As String) As Boolean

    _.........
    Dim rowsAffected = Adapter.Update(...all params go here)
    Return rowsAffected = 1

    End Function


    Is there a way to generate that code or at least part of it?
    Last edited by tutus; Apr 8th, 2008 at 09:35 AM. Reason: reviewed
    Thanks a lot for your help.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    I am not sure what you are asking for. Which code do you need generated? Is it the actual code that performs the update? Or do you mean placeholder methods?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    the following code:
    Public Function Update_CarnetAddress(ByVal id As Integer, ByVal Entreprise As String, ByVal Contact As String, ByVal Telephone As String, ByVal Email As String, ByVal Fax As String, ByVal Note As String, ByVal ModifierPar As String)

    I don t want to type it manually. Imagine if I need a method that has 15 or 25 parameters. I want that generated automatically, is there a way or a tool, as far as u know dear Mendhak ?
    Thanks a lot for your help.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    Had it been an event, my answer would have been different, but since this is a method, there isn't really a way to do this. The reason is, you may not always want all 20 parameters. You may want to work with the same object in different ways with different parameters. That's what makes the business layer a business layer - the vagueness.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    ok since professionals re just doing it that way, m gonna do the same.
    thnx
    Thanks a lot for your help.

  6. #6
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    I suggest looking through the tutorials at

    http://msdn2.microsoft.com/en-us/library/aa581787.aspx

    They answer your questions and much more. Whenever I use Sql Server 2005, I always use object data sources...

    /henrik

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    Hi MrNorth, I dont think u understood my question (no bad intention):
    In my question: I want this code:

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
    public Northwind.EmployeesDataTable GetEmployeesByHiredDateMonth(int month)
    {
    return Adapter.GetEmployeesByHiredDateMonth(month);
    }


    from the link u sent me, to be genrated automatically, I don t want to type it. Imagine, having to type an update method that has 25 arguments, that d be a lot of my day spend typing the constructor for the update method in the BLL
    Thanks a lot for your help.

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    Just to confirm your thoughts, while you could alleviate your problem more 'immediately' by simply passing a single object that contains all those parameters, at some point you will still need to populate the 25 fields. So if you eliminate it in one place, it's going to show up somewhere else.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automati

    Quote Originally Posted by mendhak
    Just to confirm your thoughts, while you could alleviate your problem more 'immediately' by simply passing a single object that contains all those parameters, at some point you will still need to populate the 25 fields. So if you eliminate it in one place, it's going to show up somewhere else.
    except if it s bound to us autoamtically , without assigbing the values to each property. Let s say, if we could set the DataObjectTypeName property to with the ProductRow generated by the TableAdapter for the Products Table. The row can be bound from the presentation <% Bind(",,," %> automatically, so we won t have to set each property.

    But unfortunately, for now, the DataObjectTypeName can t be set to the TableRow classes generated by the TableAdapter. so let s wait
    Thanks a lot for your help.

  10. #10
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automaticall

    It seems to me what your asking for is a code generation tool. One I use is code smith - http://www.codesmithtools.com .

    BLL as stated to you is not like a typed data set it is business logic and there is no way for a machine to create your logic for you.

    However the tool suggested and other like it are made to connect to databases and using predefined templates or ones you design yourself spit out code in the desired language. So if you want generic BLL methods it's an option but rather defeats the point of a BLL.. why not just leave it out and have one less teir to deal with.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: [2005] ObjectDatasource and BLL model: how to generate BLL basic methods automati

    Quote Originally Posted by brin351
    It seems to me what your asking for is a code generation tool. One I use is code smith - http://www.codesmithtools.com .

    BLL as stated to you is not like a typed data set it is business logic and there is no way for a machine to create your logic for you.

    However the tool suggested and other like it are made to connect to databases and using predefined templates or ones you design yourself spit out code in the desired language. So if you want generic BLL methods it's an option but rather defeats the point of a BLL.. why not just leave it out and have one less teir to deal with.
    very nice analysis. thx a lot.

    On the other hand, just wanted to let know about this tip:
    If u go to the genrated select or insert command text in the tableadpater, u copy the fields from the command text, when u do a paste in the BLL method, then u get the methods arguments generated for u, and the VS2005 adds the ByVal for ui automatically, it savec a lot of pain. The only thing I have not found how to do yet: the IDE doesn t paste the types of each argument, may be we ll find that.

    Thanks a lot for the code genration tool, I will try to explore it and c if there is any quickstart or how to use it, I embrace new tools very slowly it s just hard for me. great week end, great people
    Thanks a lot for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width