Example of ListFactory Update Method

Example of ListFactory Update Method

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


csmith1 posted on Tuesday, February 08, 2011

I have a working ListFactory Update method but I like to look at an example if there is one out there. My solution required me to make some protected methods public in the list (like the deleted list). This makes me think there may be a better solution.

I looked in the 2008 Business Objects and new Using CSLA 4.0 objects. I may be missing something but I can not find an example or outline. I also have the latest video series.

RockfordLhotka replied on Tuesday, February 08, 2011

This is covered in the upcoming Using CSLA 4: Data Access ebook I'm writing right now.

You are looking for the ObjectFactory base class in Csla.Server. Inherit from this and use the protected methods it exposes to break encapsulation and modify the private state and metastate of your business objects.

csmith1 replied on Tuesday, February 08, 2011

Thanks

I found the GetDeletedList function.

The steps I am taking are:

Create a new List

Get the Deleted List

Iterate through the Deleted list, calling Update on each item in the list to delete the item from the database.

Then I iterate through the passed in list.

If the item IsDirty == true then I call update and it to the new list.

If the item IsDirty == false then I clone it and add it to the new list.

Is there something I am missing?

 

RockfordLhotka replied on Tuesday, February 08, 2011

I wouldn't create a new list. I do this:

  1. Iterate through DeletedList calling Update on each item
  2. Call DeletedList.Clear()
  3. Iterate through the business list calling Update on each item
  4. Return the business list as a result

csmith1 replied on Wednesday, February 09, 2011

Thanks again for the great support.

Copyright (c) Marimer LLC