Loading Nested Objects
There will be many cases were a server request will reference objects that require another request to fully fill out. Some examples could be collections like a Flickr Photostream, which is a collection of discreet Photo objects. Another example would be
when merging data from multiple services, such as one service gives you statistics about a company and another gets its current stock price.
In these cases, DataManager will do most of the work for you and you can make them easily data bindable by exposing properties with the following pattern.
In general you use the following pattern. In this case a weather report is coming from one service, and that look up is done via a zip code. Turning that zip code into a city name is done by another service, so we have two separate calls:
[CachePolicy(CachePolicy.ValidCacheOnly, 60 * 15)]
public class WeatherForecastVm : ModelItemBase<ZipCodeLoadContext>
public WeatherForecastVm(string zipcode): base(new ZipCodeLoadContext(zipcode))
/// ZipCode info is the name of the city for the zipcode. This is a sepearate
/// service lookup, so we treat it seperately.
public ZipCodeVm ZipCodeInfo
Note that we pass any calls to ZipCodeInfo down to the DataManager to load the separate object. This allows us to manage the lifetimes of the data separately (the cache policy for the zip code is
CachePolicy.Forever), whereas we need to update the weather data more frequently.