BusinessListBase MarkOld() is empty?

BusinessListBase MarkOld() is empty?

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


billtylerjr posted on Wednesday, March 31, 2010

Hello, I am new to CSLA so please excuse me if this is trivial as I am trying to get my head around the framework.  I am reading the BO 2008 book while working on my first implementation.

I am having an issue with retrieving root objects from an object list factory.  When I get the list of objects from the database they are all marked as new and when I save changes they get inserted rather than updated.  When I dig into this I see that BusinessListBase implements a MarkOld method but it is an empty method.  However if I fetch a single object is is marked correctly as old.

Can someone please point me in the direction to figure this out?  I am sure I just havn't found something simple yet.

Thanks, Bill

billtylerjr replied on Wednesday, March 31, 2010

I forgot to mention that I am using 3.8.2.

RockfordLhotka replied on Wednesday, March 31, 2010

If you are using the DataPortal_Fetch() method to get the list, that method should be calling DataPortal.FetchChild() to get each child object. That will automatically set the metastate of the child objects as they are created.

If you are using an object factory then you must explicitly call MarkOld() on each child object. The easiest way to do this is to have your factory object inherit from ObjectFactory, which as a protected MarkOld() method for your use.

Or if you are using a pre-3.5 style of coding with DataPortal_Fetch() (so you aren't using the child data portal feature) then you really need to look at the older 2005 book or the older ProjectTracker versions to see how child objects call MarkOld() themselves as they are created. The reason for creating the child data portal functionality was to eliminate this old style of coding, because it was too easy for people to forget key bits of code.

JoeFallon1 replied on Wednesday, March 31, 2010

When you use a factory you become responsible for setting the state to New or Old among many other things.

If you use the DataPortal_XYZ methods instead then the framework will handle it for you.

Joe

 

billtylerjr replied on Wednesday, March 31, 2010

When I fetch a single object rather than a list it works just fine.  It calls this.MarkOld from business base.

How would I go about handling this myself?  Forgive me for the nubie questions.

Thanks for the quick response.

rsbaker0 replied on Wednesday, March 31, 2010

billtylerjr

When I fetch a single object rather than a list it works just fine.  It calls this.MarkOld from business base.

How would I go about handling this myself?  Forgive me for the nubie questions.

Thanks for the quick response.

I think this is an issue of doing MarkOld() on each object in the list as you fetch it.  (I'll have to review what we did as this is from memory).   I started with CSLA before there was an object factory or child data portal, but the child data portal does a lot of work for you that I had previously implemented manaually.

Copyright (c) Marimer LLC