Ok, we now have a Trainee object, an IDataProvider and TraineeDataContract class to formalize how we retrieve and save trainees, and an SqlDataProvider to actually talk to the database. We even have some tests to prove that they work (so far). All we need now is a way to change TraineeDataContract instances to Trainee instances, and back again.

This started pretty simple, but I expect we'll make it a bit more powerful later on. For now, we have a new constructor in our Trainee object which will let us create a Trainee from a TraineeDataContract:

 public Trainee(TraineeDataContract tdc) { ID = tdc.ID; FirstName = tdc.FirstName; LastName = tdc.LastName; IsActive = tdc.IsActive; }

... and a new method to convert back:

 public TraineeDataContract ToDataContract() { TraineeDataContract tdc = new TraineeDataContract(); tdc.ID = _id; tdc.FirstName = _firstName; tdc.LastName = _lastName; tdc.IsActive = _isActive; return tdc; }

I'm thinking that eventually we'll create a new TraineeCollection class (derived from ObservableCollection<Trainee>) in our object model, and give it a constructor that accepts an IList<TraineeDataContract>, so it can create a whole bunch of Trainee objects at once.

Looking good so far! Part 6 isn't written yet, because our next meeting hasn't happened. The next thing I'm thinking about is how to formalize the structure of a trainee, perhaps with an ITrainee interface which can be implemented by both Trainee and TraineeDataContract. Stay tuned!