/// <inheritdoc />
        public void Complete(IConnectionFactory factory, bool success)
        {
            if (factory == _readOnlyFactory)
            {
                _readOnlyFactory = null;
            }

            if (factory == Factory)
            {
                _countsHelper = null;
                Factory       = null;
            }
        }
        /// <inheritdoc />
        public void Prepare(IPersister persister, IConnectionFactory factory)
        {
            // save non readonly factory
            if (Factory == null && !factory.IsReadOnly)
            {
                Factory = factory;

                Contract.Assert(_countsHelper == null);
                _countsHelper = new CountsHelper(factory, Tables.Counts);
            }

            // save the readonly factory
            if (_readOnlyFactory == null && factory.IsReadOnly)
            {
                _readOnlyFactory = factory;
            }
        }