Loading defaults using another BO

Loading defaults using another BO

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


juddaman posted on Thursday, August 16, 2007

Hi

As part of the creation routine for one of my BO's I am retriving a list (an instance of another BO), looping through it and depending on the data in the list adding an element to the list in the BO. Although I've read that when loading defaults from the database the code should be in the DataPortal_Create method, however as I'm using another BO to do the actual fetch, I'm presuming there would be no harm in putting this code in the static creation method? This then bypassess the need for me to use a criteria object for creation. Thoughts appreciated.

George

 

Plowking replied on Thursday, August 16, 2007

That sounds fine. Like you say, the way to look at it (and its only strictly relevant if you have a remote data portal, or you are abstracting your data access code in some other way) is that data access code should be in the DataPortal methods. The only data access you make when creating your new object is done within your list objects DataPortal_Fetch when it fetches itself, so there's no problem.

Ian

Marjon1 replied on Thursday, August 16, 2007

George,

I've just had the fun of refactoring our business objects because we had lists which have a default value property being called as part of the variable declaration. This worked fine as you would expect, but when doing a delete on the business object we started to get MSDTC errors; because the DataPortal_Delete method created an instance of the class, triggering multiple fetches which caused multiple connections within a transaction. 

I assume the same would apply if you put this in a constructor, but if I understand you correctly and you put this code into the actual factory method itself you should be fine.

Other than this it works fantastic!

juddaman replied on Thursday, August 16, 2007

Thanks for the comments, its always nice to get a bit of reassurance:-) Marjon - thanks for the warning! I had planned on placing the code in the static method however, as I only require the "defaults" to be loaded on the creation of a new BO.

Thanks

George

Copyright (c) Marimer LLC