CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Example of ListFactory Update Method

    rated by 0 users
    Answered (Verified) This post has 2 verified answers | 4 Replies | 2 Followers

    Top 500 Contributor
    27 Posts
    csmith1 posted on Tue, Feb 8 2011 2:29 PM

    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.

    Answered (Verified) Verified Answer

    Top 10 Contributor
    9,475 Posts
    Verified by csmith1

    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.

    Rocky

    Top 10 Contributor
    9,475 Posts
    Verified by csmith1

    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

    Rocky

    All Replies

    Top 10 Contributor
    9,475 Posts
    Verified by csmith1

    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.

    Rocky

    Top 500 Contributor
    27 Posts

    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?

     

    Top 10 Contributor
    9,475 Posts
    Verified by csmith1

    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

    Rocky

    Top 500 Contributor
    27 Posts

    Thanks again for the great support.

    Page 1 of 1 (5 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems