Refresh Lists and BOs

Refresh Lists and BOs

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


kyle.l.watson@gmail.com posted on Thursday, January 29, 2009

Using the project tracker example, what is the best pattern for refreshing lookup Values in the ResourceProject / ProjectResource BO's when a user changes values in a Project / Resource.

I noticed in the application you can edit a project, then edit a Resource, change the resource's First and Last Name name and save the resource. The edit project should still be opened and would now show a name that isn't correctly refreshed.

My thoughts are:

Add a refresh method that can be called by the UI.

The refresh would have two ways to refresh.

 1. Refresh from the database using a command object. In this scenario would you mark the BO as clean using the markclean method?

2. Perhaps the Refresh method accepts an overload like 'Refresh(Resource resource)'. Basically taking in a resource object and setting its readonly first and last name to the resource. For example:

Project Class
{

public void Refresh(Resource aresource)

{
       if ( this.Resource.Contains(aresource.Id)

          {

               ProjectResource aprojres = this.Resources.GetItem(ares.Id);

               aprojres.Refresh( aresource );
          }
}
}

ProjectResource
{

internal void Refresh( Resource aresource )
{
  LoadProperty(LastNameProperty, aresource.LastName);
  LoadProperty(FirstNameProperty, aresource.FirstName);
}

}

Of course, you could get a completely new list like in the project tracker example each time but this could be inefficent if you have a medium or large list.

Is there a better pattern to implement refreshing on your BO's? I can certainly see having a list of a thousand read only items and wanting to update some of them as you modify your BOs.

 

Copyright (c) Marimer LLC