Conceptual question

Conceptual question

Old forum URL: forums.lhotka.net/forums/t/3666.aspx


Angel posted on Monday, October 08, 2007

I'm new in OOP and still I have datacentric thought.

I have a question about update methods on CSLA

    If the update of a business object has responsibility of update or create other objects (like a stock movement, or accounting references. Is correct to manage objects in Dataportal_XYZ methods or Dataportal methos are only for data access:

 

            Is Normal do things like

 

            Partial Class Bill

                        (…)

                        Sub DataPortal_Update()

                                  

(...)               

                                   Dim vM as StockMovement

                                   vM = StockMovement.CreateStockMovement

                                   (….)

                                   vM= vM.Save

 

                        (…)

           

                                  

      Using the same transaction scope or sharing conection and transaction?

 

      Or this should be done at store procedure that updates the bill object?

     What pattern do you use to solve things like this?

 

 

JoeFallon1 replied on Monday, October 08, 2007

I think it is OK to handle other activities within the DataPortal. Especially if they require the same transaction scope. Rcoky has recommended the creation of a special command object to control all of the other objects and set up a single transaction. I use the same idea with a normal root BO which is a Use Case Controller. This allows me to also have high level rules within the controller BO. This object also controls the entire Save activity.

Joe

 

Angel replied on Monday, October 08, 2007

The idea is to share transaction connection between diferent objects, perhaps with LocalContext or other own way.

I will generate objects that will be called inside dataportal methods (or not).

What problems could find using this technique?

DataPortal_update()

   GetActiveTransaction

   BeginTransaction...

   Try

   Some new objects ussage with Save and delete methods (dataportal Calls)

   That will use the same transaction

  catch

      Rollback

      throw exception

   end

    commit

  End

I will use manual transactions because I have to work with SQL 7.

JoeFallon1 replied on Monday, October 08, 2007

Thta is almost exactly the same technique I use.

If you search this forum you may find all the support code I shared about a year ago.

I added some code to BusinessBase so that it would be easier to share the transaction.

Joe

Angel replied on Tuesday, October 09, 2007

Thanks for your support

Can you give me some keys to find these posts, I'm very interested.

JoeFallon1 replied on Tuesday, October 09, 2007

I searched on BeginTransaction and found this:

http://forums.lhotka.net/forums/thread/9066.aspx

Be sure to search for Rocky's CommandBase solution so you can look at it in a different way too.

Joe

 

 

Copyright (c) Marimer LLC