[Previous] [TOC] [Next]

Persistence (Perhaps?)

So now we can retrieve worker objects from the database, we can add them to other factories, and we can create new ones-all well and good-but what about saving them back to the data source? This is the role of persistence. Basically, persistence involves sending the recordset back to the database to be updated. The DAL has a method that does exactly that-UpdateRecordset-and we can also supply and retrieve any parameters that might be appropriate for the update operation (although most of the time UpdateRecordset tends to happen without any reliance on parameters at all).

Dim ocDAL            As New cDAL
  Dim ocfEmployees     As New cfEmployees
  Dim ocwEmployee      As New cwEmployee
  Dim ocParams         As New cParams

  ocfEmployees.Create ocDAL
  ocParams.Add "Department", "Engineering"
  ocfEmployees.Populate ocParams
  For Each ocwEmployee In ocfEmployees
      .Salary = "Peanuts"
  Next  'ocwEmployee
  ocfEmployees.Persist     ' Reduce costs

What is this Persist method doing, then?

Public Sub Persist(Optional i_ocParams As cParams)
      oPicDAL.UpdateRecordset oPicRecordset, i_ocParams
  End Sub

Consider it persisted.

[Previous] [TOC] [Next]