|Number of votes:||4|
This is the second part of my blog post series Content Providers 101. Make sure you’ve read Part I before reading this post.
In order to update or write Person objects to the text file, we’ll need to override the Save method. The Save method will occur whenever a draft has been created, autosaved or published. The drafts are kept in-memory in this example (in the _attendees property), but they could have been saved back to the source(PersonService) had the service supported it. They could also have been saved to the dynamic data store or similar data sources.
LoadContent also needs to be modified in order to load the in-memory items, and not just directly from the PersonService:
With this in place, we can create and update content directly to the text file.
Being able to create, read and update, we should also be able to delete content. This is done by overriding Delete in the provider:
To remove content from the text file, PersonService.Delete is invoked. The mapping in the IdentityMappingService is also deleted as we wouldn’t want lots of unused mapping laying around.
CRUD operations are now in place, but there are a few things left. We’ll put the finishing touches to it in Part III