This project is read-only.

Upcoming Changes - Rewriting Data Layer

Jun 23, 2010 at 3:46 AM
Edited Jun 23, 2010 at 3:50 AM

I am in the middle of re-writing the data abstraction layer for WeBlog. I have really made some nice improvements with the XML provider which will significantly clean up the code. You can now persist to XML by returning an object, modifying it and then call Save. 

xmlRepo = new XMLRepository { RootDirectory = new DirectoryInfo(@"..\..\App_Data") };                        
var posts = xmlRepo.All<Post>();                
posts.First().Slug = "modified";            
xmlRepo.Save();

This works because my model objects which are using the EF4 POCO templates, implement the INotifyPropertyChanged interface. In the XML Repository object I subscribe to the PropertyChanged event for each returned item. When a property is changed I add it to a list of "dirty" objects. When you call Save() I iterate through the list of dirty objects and call the Save() event on each item which persists them back to XML.

The concept behind having an XML provider with automatic change tracking is freaking awesome. Hopefully the new implementation will hold water as I get further into testing.