Seeing everything that is persisted

There is something called a ChainedPersistenceHandlerBase that you can inherit from and intercept everything that goes to and from the database.

You can use override as you see fit:

  1. namespace Eco.Persistence
  2. {
  3.   // Summary:
  4.   //     Base class for persistence handler.
  5.   //
  6.   // Remarks:
  7.   //     Use this class to implement your own IPersistenceHandler override any of
  8.   //     the virtual methods to inject your own behaviour and copy the Install-procedure
  9.   //     (from the source of this class) for a convenient way to install the new class
  10.   //     in the EcoSpace.
  11.   public class ChainedPersistenceHandlerBase : IPersistenceHandler
  12.   {
  13.     public ChainedPersistenceHandlerBase(IEcoTypeSystem typeSystem);
  14.  
  15.     public bool IsPersistent { get; }
  16.     public virtual int MaxSavedVersion { get; }
  17.     public IPersistenceHandler NextPersistenceHandler { get; set; }
  18.     public bool SupportsSync { get; }
  19.     protected IEcoTypeSystem TypeSystem { get; }
  20.  
  21.     public virtual event LocatorArrayEventHandler ObjectsUpdated;
  22.  
  23.     public virtual void Fetch(ICollection<Locator> locators, int[] members, FetchStrategy FetchStrategy);
  24.     public virtual ICollection<Locator> FetchLinksWithObjects(ICollection<Locator> objects, IAssociationEnd assocEnd);
  25.     public virtual ICollection<Locator> GetAllWithCondition(AbstractCondition condition, int maxAnswers, int offset);
  26.     public virtual Datablock GetValueWithCondition(AbstractCondition condition, int maxAnswers, int offset);
  27.     public virtual void RetrieveChanges(out DBChangeCollection ignoredChanges);
  28.     public virtual DateTime TimeForVersion(int version);
  29.     public virtual void UpdateDatabaseWithList(ICollection<Locator> locators);
  30.     public virtual int VersionAtTime(DateTime time);
  31.   }
  32. }


Maybe you have a common base class for all classes in your model, and maybe this class implements an Interface ITrackUpdate, then it would be a good thing to catch all updates and set the datetime…

We need to install our ChainedPersistenceHandlerBase baseclass. We do this by mixing it in before the current persistencehandler , we do this in the ecospace – before we go active:

This page was edited 78 days ago on 02/10/2024. What links here