Exercise 4: Track and Session Hierarchy
Events won’t be very interesting if they have no sessions for attendees to listen to. So our event editing page also needs to provide a list of the tracks in the event, along with the sessions for each track. So we’ll need to add two data grids to our event editor, but we also need to modify the service to ensure that all the necessary entities are available.
The domain service operation our Silverlight application currently uses to get event information only returns Event entities. The GetEvents method in the EventManagerDomainService just returns the ObjectContext.Events query, and by default, the Entity Framework does not automatically fetch related entities. (It can perform automatic deferred fetching, but by the time the entities have been returned back to the Silverlight client it’s too late for this to happen because the Entity Framework is no longer in the picture. Its work is already done by then.)
For the Home.xaml, this is what we want. Our page shows a list of all the events, so we really don’t want to fetch all related data for all events as it would make the page too slow to load. However, for the individual event editing page, we do need to fetch the related track and session items.
Creating a Custom Domain Service Query
Allow Related Objects to be Serialized
Implement Adding Tracks and Talks