Refreshing a dataset list (multi-model)

Hi,

I have created a database (SQLite) in which I have defined Views that I use for data selection.  The view is merely selection of only a few fields (relevant for selection) of the underlying table.  For the view(s), I create new entities manually (copy & paste with some mod's)  in a separate unit and assign them to a different model. As such I have the models 'Database' (for CRUD) and 'Views' for display and selection.

This all works well, but now facing an issue that would merely require Close/Open is using standard queries; after adding a new entity in the 'Database' model, I'd like to refresh the data in the selection dataset for the 'View' model.  I am fairly new to Aurelius, so I am struggling to find the best solution.  So far I have come up with this, which seems to work OK without mem leaks:

var
  dlgNew: TdlgNew;
  LMyEntity: TMyEntity;         // Entity for model 'Database'
  LMyEntityView: TMyEntityView; // Entity for model 'View'
  LMsg: string;
begin
  dlgNew := TdlgNew.Create(self);
  try
    if dlgNew.ShowModal = mrOk then
    begin
      try
        LMyEntity := TMyEntity.Create; // Create entity and set properties
        LMyEntity.FirstProperty := dlgNew.FirstProperty
        ...
        ...
        ObjMgr_Database.Save(LMyEntity); // Persist to DB, using manager for 'Database' model.
        LMyEntityView := ObjMgr_View.ObjManager.Find<TSchematicView>(LMyEntity.ID); // Get object for model 'View' using ID from LMyEntity
        FMyEntityViewList.Add(LMyEntityView);                                              // Add to the global list (SourceList for 'View' dataset)
        DataSet_View.Refresh;                                                       // Refresh the dataset to show (include) the new entity
      except
        on E: Exception do
        begin
          // Notify user....
        end;
      end;
    end;
  finally
    dlgNew.Free;
  end;

Because the entity is added in a different model, I realized I need a "Refetch", rather than a Refresh.
Is the above a good approach or is there a more elegant solution?  Typically, this setup (second model for views/selection) will be required often (database applications), so the more efficient, the better.

Thanks for your consideration!

Hi Mark,

That's a good approach indeed, it's correct.